symfony2 CSRF invalid

前端 未结 3 502
深忆病人
深忆病人 2020-12-08 08:14

Okay, so today I updated my database with new information from our \'live\' database... And since then I\'ve been having issues on one of my forms. If you need any code le

3条回答
  •  抹茶落季
    2020-12-08 08:23

    Are you by chance using $form->bindRequest() in the action which produces the CSRF error? I had this issue. You should not be binding the request for a new form. If you are posting the form to the same action, wrap the bindRequest in a conditional which checks if method is POST:

    if ($this->getRequest()->getMethod() == 'POST') {
      $form->bindRequest($this->getRequest());
      if ($form->isValid()) {
        ...
      }
    }
    

提交回复
热议问题