I am putting together a Zend_Form that has numerous SubForms. In fact, it has the potential to have so many subforms, I'd like them to appear on multiple pages. Is it possible to use Zend_Paginator to create a multipage form of some dynamic number of pages?
Here's a more concrete example. I am creating a page where someone can edit the metadata on numerous photographs in a single gallery. So, they hit edit and it pulls all of the images from the Database. The page is a Master form and each of the images are placed into a subform. This works great if I only want one page and they all show up. I have that working just fine.
Now, say there are 200 images. Clearly, you don't want all 200 images to load at once, so I would love the ability for the user to page through say 20 images at a time. I don't really care if the pages are processed one at at time or if the values are stored until then end like a true multi-page form and then processed all at once.
I've tried passing the image data to a paginator and then dynamically add the subform within a partial loop. This is an issues because inside the partial loop in the view, it can't see the Master Form which I need to access to in order to add the subform ($this->form->addSubform()).
The next idea is to manually create a paginator using Limits on the DB query and let it page through the data that way. Not ideal but I think it would work.
Any ideas on a smoother integration? Thanks for the help!
I think Zend_Paginator is a good solution for you. Using a Zend_Db_Select or Zend_Db_Table_Select adapter you can retrieve only the smallest amount of data necessary for displaying the current page.
However multi-page forms are not supported by zend framework yet. But there seems to be a workaround: http://framework.zend.com/manual/en/zend.form.advanced.html#zend.form.advanced.multiPage
Currently, Multi-Page forms are not officially supported in Zend_Form; however, most support for implementing them is available and can be utilized with a little extra tooling.
You could think about using just javascript and jQuery to handle editing of image information. Just define you forms straight in you html and access it with jQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With