开发者

What is the most idiomatic way to paginate through the results of a search performed using zend_form

I've implemented an action + view that lists all the rows in a database and allows you to paginate through them using zend_paginator. I've also written an action + view that takes a form post (or get), constructs a Solr query and returns a zend_paginator adapter to page through the results.

The problem I've got is working out how to paginate through my query after the postback, it's a relatively complex search form (8 fields to search on).

The options as far as I can see are:

  • Move the parameters that are posted to a new url and redirect
  • Write my own paginator that preserve query string parameters
  • Serialize the results of the form post into a session and get it from there when paginating

Which of t开发者_运维百科hese is the most zend/php way of doing it - and, more importantly, quickest to implement? HELP!!!!! Thanks.


I'm not going to accept this answer until I'm convince no one has a better one but I've come to a decision. I've gone for the PRG pattern (post-redirect-get).

    if ($request->isPost()) {
        if ($form->isValid($request->getPost())) {
            return $this->_helper->redirector('index','contact',NULL,array_filter($form->getValues()));
        }
    }

This redirects to a url with the contents of the form as parameters - www.url.com/form/param1/val/param2/val

The array_filter command strips all empty parameters and this means you end up with a nice clean, bookmarkable, seo friendly url that the zend_paginator works with out the box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜