Zend_Form 和 Zend_Form分页
我正在整理一个具有许多子表单的 Zend_Form。事实上,它有可能拥有如此多的子表单,我希望它们出现在多个页面上。是否可以使用 Zend_Paginator 创建一些动态页面数的多页形式?
这是一个更具体的例子。我正在创建一个页面,人们可以在其中编辑单个画廊中大量照片的元数据。因此,他们点击编辑,它从数据库中提取所有图像。该页面是一个主表单,每个图像都放置在一个子表单中。如果我只想要一页并且它们全部显示出来,那么这非常有用。我的那个工作得很好。
现在,假设有 200 张图像。显然,您不希望一次加载所有 200 张图像,因此我希望用户能够一次翻阅 20 张图像。我并不真正关心这些页面是否一次处理一个页面,或者这些值是否像真正的多页面表单一样存储到那时结束,然后一次全部处理。
我尝试将图像数据传递到分页器,然后在部分循环中动态添加子表单。这是一个问题,因为在视图的部分循环内,它看不到我需要访问以添加子表单的主表单($this->form->addSubform())。
下一个想法是使用数据库查询上的限制手动创建分页器,并让它以这种方式对数据进行分页。不理想,但我认为它会起作用。
关于更顺利的集成有什么想法吗?感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 Zend_Paginator 是为您提供一个好的解决方案。使用 Zend_Db_Select 或 Zend_Db_Table_Select 适配器,您只能检索最小的显示当前页面所需的数据量。
然而,zend 框架尚不支持多页表单。但似乎有一个解决方法: http ://framework.zend.com/manual/en/zend.form.advanced.html#zend.form.advanced.multiPage
您可以考虑仅使用 javascript 和 jQuery 来处理图像信息的编辑。只需直接在 html 中定义表单并使用 jQuery 访问它即可。
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
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.