2009年9月16日星期三

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

-- Exception e <exceptione@hotmail.com> wrote
(on Wednesday, 16 September 2009, 06:41 AM -0700):
> I've a html form that enables users to search in a database.
> The http://www.w3.org/TR/html401/interact/forms.html#h-17.13 W3C recommends
> to use a GET method for this scenario. Posting a get form leads invariably
> to a URI with a query part (e.g. ?key[]=a&key[]=b&foo=1)
>
> My question: How do I create the query part of a URI programmatically from
> an array in that form? I need this to generate hyperlinks.
>
> I can use the URL view helper, but this will create, following the example,
> something like this
>
> key/a/key/b/foo/1
>
> This is inconsisten with how GET-forms work. How can I pull out a real query
> part?

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>

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: