Skip to content

Commit 1f55e90

Browse files
committed
minor #10545 Update form.rst (Ferikl)
This PR was submitted for the 4.1 branch but it was squashed and merged into the 2.8 branch instead (closes #10545). Discussion ---------- Update form.rst Add example how to disable CSRF in Form <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- fc24a02 Update form.rst
2 parents ed81ff5 + fc24a02 commit 1f55e90

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

components/form.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ the CSRF generator and validated when binding the form.
156156

157157
$csrfStorage = new NativeSessionTokenStorage();
158158
// ...
159+
160+
.. tip::
161+
If you want to disable CSRF on your form, you can give specific options to your form builder through the createBuilder() function:
162+
163+
use Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType
164+
165+
$form = $formFactory->createBuilder(FormType::class, null, ['csrf_protection' => false])
159166

160167
Twig Templating
161168
~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)