On Wed, Jul 14, 2010 at 4:06 PM, Hector Virgen <[email protected]> wrote:

> By default, web browsers submit GET forms using the ?foo=bar
> syntax. There's nothing that ZF nor PHP can do to change this, because it
> all happens on the client side. So the only way to get pretty URLs is to use
> Javascript to override the default behavior.
>
> The only way to get this to work using server-side code is to perform a
> redirect, which is an expensive process, so I don't suggest it.
>
> Regarding a JS solution, you'll need to be sure that you implement this in
> a way that is consistent with how forms are normally submitted. For example,
> if your form has two inputs by the same name, only the value of the last
> input is submitted (it overwrites the previous ones). But if you use array
> notation, then you can have multiple values for the same name, and they will
> all be submitted and PHP will read them as an array. AFAIK this can be
> difficult to do with the ZF router because it doesn't turn multiple values
> into arrays.
>
> Also, if your form has multiple submit buttons, each with their own actions
> (like "post" versus "cancel" buttons) then you'll need to submit the value
> for the button that was clicked.
>
> And finally, supporting this may have an impact on your controllers. If you
> are using $this->_request->getQuery() to read the values, note that it only
> reads from $_GET (by default). So if you rewrite your URL using Javascript,
> you'll only be able to use $this->_request->getParam() because $_GET will be
> empty.
>
> With that being said, it's a lot of work for very little benefit. But if
> you have a simple form with only a few elements, then you may not run into
> any problems supporting it.
>


Interesting points. My case is just a fairly simply search form for a roster
of language interpreters. The user selects a language and submits, the
controller action queries a db and uses Zend_Paginate for pagination. The
pagination links give you pretty URLs but the initial form submission is of
course contrastingly "ugly."  Not really a big deal. I think I will let it
go for now and concentrate on more important areas.

@Wil, thanks for the suggestion. I confess I don't quite get it but that's
an opportunity for further RTFM.


-- 
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/

Reply via email to