Search code examples
phpformszend-frameworkgetsubmit

zend framework urls and get method


I am developing a website using zend framework.

i have a search form with get method. when the user clicks submit button the query string appears in the url after ? mark. but i want it to be zend like url.

is it possible?


Solution

  • As well as the JS approach you can do a redirect back to the preferred URL you want. I.e. let the form submit via GET, then redirect to the ZF routing style.

    This is, however, overkill unless you have a really good reason to want to create neat URLs for your search queries. Generally speaking a search form should send a GET query that can be bookmarked. And there's nothing wrong with ?param=val style parameters in a URL :-)

    ZF URLs are a little odd in that they force URL parameters to be part of the main URL. I.e. domain.com/controller/action/param/val/param2/val rather than domain.com/controller/action?param=val&param2=val

    This isn't always what you want, but seems to be the way frameworks are going with URL parameters