/** * Renders submit action * * @return String */ public function submitAction() { /** * Some explanation on what happens here: * * 1. We check whether filter validates. If not, we set error in template and forward to 'show' * 2. Whenever a filter is submitted, this action is called. Previously active state of filter is stored in session, so * we have to reset this. Active state for filterbox is set in init() of filterbox again, if GP vars are available. * 3. We have to reset the pagers, as changed filter state normally means changed pager state * 4. We check, whether we have a redirect on submit configured for this filter and do the redirect if we have done so */ if (!$this->filterbox->validate()) { $this->view->assign('filtersDontValidate', true); $this->forward('show'); } $this->filterboxCollection->resetIsSubmittedFilterbox(); $this->resetPagers(); if ($this->filterbox->getFilterboxConfiguration()->getResetToDefaultSortingOnSubmit()) { $this->resetSorter(); } // check whether we have a redirect on submit configured for this filter if ($this->filterbox->isSubmittedFilterbox() && $this->filterbox->getFilterboxConfiguration()->doRedirectOnSubmit()) { $this->redirect($this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitActionName(), $this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitControllerName(), null, null, $this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitPageId()); } if ($this->configurationBuilder->getSettings('redirectOnSubmitFilter') == 1) { /** * Whenever a filter is not first widget on page, we have to do a redirect * for reset pager and all other components whenever a filter values changed */ $this->redirect('show'); } else { $this->forward('show'); } }
/** @test */ public function filterboxDoesNotValidateOnNonValidatingFilters() { $notValidatingFilterboxMock = new Tx_PtExtlist_Domain_Model_Filter_Filterbox(); $notValidatingFilterboxMock->_injectFilterboxConfiguration(new Tx_PtExtlist_Domain_Configuration_Filters_FilterboxConfig($this->configurationBuilderMock, 'test', array())); $notValidatingFilterMock = $this->getMock('Tx_PtExtlist_Tests_Domain_Model_Filter_Stubs_FilterStub', array('validate'), array(), '', false); $notValidatingFilterMock->expects($this->once())->method('validate')->will($this->returnValue(false)); $notValidatingFilterboxMock->addItem($notValidatingFilterMock); $this->assertFalse($notValidatingFilterboxMock->validate()); }