开发者

Symfony clear Post data

开发者 https://www.devze.com 2023-02-11 15:22 出处:网络
I need to clear the POST data ($request->getPostParameter()) so that if the user r开发者_开发百科efreshes the page the data does not get resubmitted. How do I do this in symfony? The general rule i

I need to clear the POST data ($request->getPostParameter()) so that if the user r开发者_开发百科efreshes the page the data does not get resubmitted. How do I do this in symfony?


The general rule in symfony is to redirect (not forward) in a controller that accepts post data, and presumably writes to the database. You can this behaviour in the generated action.class.php when using generate-module


I needed to reload previously loaded page without redirect, because the request was sent by ajax... so I processed the form and then just changed method from POST to GET, which prevent form resubmittion, and then forwarded request to another controller. Here is the code:

$request = $this->get('request');
$request->setMethod('GET');
$response = $this->forward($controller, $params);
return $response;
0

精彩评论

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