开发者

CakePHP - Can you make forms submit params as named params?

开发者 https://www.devze.com 2022-12-22 10:19 出处:网络
So GET forms make the usual urls like .../search/?q=apple Can you make a form create urls like .../search/q:ap开发者_JS百科ple/

So GET forms make the usual urls like

.../search/?q=apple

Can you make a form create urls like

.../search/q:ap开发者_JS百科ple/


Thanks, guys. I've found a different solution. I just submit the form as a POST and in the controller's action I read the post data and create a url with the post data as named params and then $this->redirect('...'); to it.


The methods to create these URL's can be found here: http://book.cakephp.org/view/842/url


If I understand you correctly, you're not looking to create a different URI, per se, but rather to serialize the form data in a different way. In other words, you're interested in modifying the query string rather than the URI itself.

As far as I know, that's the way that forms serialize their data and there's no way to truly override this behavior. If you really want to do this, I suspect you'll have to capture the submit event, manually serialize the form data into the format you want, append that format to the form's action value, make a custom request to the page (via location.href, etc.) and return false so that the form itself never actually gets submitted.

Of course, you could also submit via Ajax where you have a little more control.

I'm not aware of any other way to do what I think you're asking.

0

精彩评论

暂无评论...
验证码 换一张
取 消