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
This error had me crazy for days!
Thanks krishna!
If in your form template you choose to not use the default form behavior {{ form_widget(form) }}
you SHOULD put {{ form_rest(form) }}
Hope this could help anyone else!
There is no problem using {{ form_widget(form) }}
to build your custom form.
All you have to do is add the _token
like this:
{{ form_widget(form._token) }}
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()) {
...
}
}