Insert cakephp POST params into URL

假如想象 提交于 2019-12-01 01:51:53
deizel

Sounds like you are looking to do a Post/Redirect/Get.

Here are two examples of doing this in CakePHP:

The two main advantages of redirecting a POST to a GET request are:

  1. Users don't get the "Do you want to resubmit?" dialog if they refresh
  2. The resulting page/query can be bookmarked

In the action to which you post, you could simply prepare the GET url and then redirect to this url. The action for that url then does the filtering.

If I understand you correctly (and I'm not sure that I do), you can pass additional variables on the query string of the form's action quite easily. Conventionally, that might look like this:

<form id="FiltreExtraForm" action="/products/index?delivery_price=1&picture=0" method="post" name="FiltreExtraForm">

Using Cake, you should be able to do the same without the traditional query string if you'd rather (though the traditional method above will also work):

<form id="FiltreExtraForm" action="/products/index/delivery_price:1/picture:0" method="post" name="FiltreExtraForm"> 

I would recommend looking at the form helper or at least constructing the action URI using helpers, but this should get you what you're after.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!