2009年9月16日星期三

Re: [fw-mvc] howto: generate url with separators &, ? and =

Matthew Weier O'Phinney-3 wrote:
>
> Simply build a form, set the method to "get", and when it submits, it
> will supply query parameters:
>
>
> <form action="/search/process" method="get">
> <input type="text" name="q" value="" />
> <input type="submit" name="search" value="Search" />
> </form>
>

Well the problem here is that submitting the form results in

/search/process?q=text

if I then want to use the view helper Url, to create a query url for me to
use in a hyperlink, it will generate something like

/search/process/q/text

spot the difference?

Here a more detailed explanation why this is a problem.

I generate a zend_form with no absolute action uri, and method get

1) submit form → uri is now /search/process?q=text
2) click on a link built from the url helper → leads to
/search/process/q/different
3) submit form again, note that action is now /search/process/q/text → lead
to /search/process/q/different?q=other

I hope it is more clear now?


As a workaround, I use the native http_build_query now. If the url helper
doesn't perform any
http://framework.zend.com/manual/en/zend.uri.html#zend.uri.validation.allowunwise
sanity checks , then there is no reason to avoid http_build_query (which
seems the case to me).

Thanks for your answer!
--
View this message in context: http://www.nabble.com/howto%3A-generate-url-with-separators--%2C---and-%3D-tp25472630p25474426.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: