2010年3月1日星期一

Re: [fw-mvc] Re: Changing get parameters to controller/action/param/value/param/value

I can see a way to do it, but it requires a 302 redirect, so your server gets hit twice after submitting. The js approach is better IMO.

// in your controller
public function init()
{
    if (!empty($_GET)) {
        $this->getHelper('Redirector')->gotoRouteAndExit($_GET);
    }
}


   -- Mon


On Tue, Mar 2, 2010 at 12:56 PM, David Muir <davidkmuir+zend@gmail.com> wrote:

Really? I'd like to know how they did that.
The only way I know of doing that would be using javascript to replace the
action on submit.

Otherwise, what you should get is:
/controller/action?param=value

with a form:
<form action="/controller/action" method="GET">
<input type="text" name="param" value="value" />
</form>

using jQuery:
$('form').submit(function(){
   $(this).attr('action', function (index, action){
       jQuery.each($(this).serializeArray(), function(i, field){
           action += '/'+field.name+'/'+field.value;
       });
       return action;
   });
});

the form should now submit to:
/controller/action/param/value

(in theory)

David
--
View this message in context: http://n4.nabble.com/Changing-get-parameters-to-controller-action-param-value-param-value-tp1574578p1574596.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: