views:

30

answers:

2

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?

+1  A: 

There is no obvious solution. The form generated by zf will be a standard html one. When submitted from the browser using GET it will result in a request like

/action/specified/in/form?var1=val1&var2=var2

Only solution to get a "zendlike url" (one with / instead of ? or &), would be to hack the form submission using javascript. For example you can listen for onSubmit, abort the submission and instead redirect browser to a translated url. I personally don't believe this solution is worth the added complexity, but it should perform what you're looking for.

Fredrik
+1  A: 

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

simonrjones