I have a page that has a form on top for selecting filters. When submitted, this form data is used in combination with Zend paginator to display results. But when I use paginator to page through the results, the form fields are lost as paginator does not post the form. Is there a simple way to combine these? I have had a difficult time searching for this as it is difficult to explain.
my controller is of this form…
$form = new Application_Form_Myform();
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->populate($data);
// get the data
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$reportsTBL = new Model_DBTable_Reports();
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($reportsTBL->getLog($data)));
$paginator->setCurrentPageNumber($this->_getParam('page',1))
->setItemCountPerPage(50);
$this->view->paginator = $paginator
}
$this->view->form = $form;
As you can see, this gets the values from the form and retains them for first submit. But on subsequent pagination clicks, they get lost.
Thanks!
So simple, Use Zend Session to keep your filters .
Something like this