Skip to content

Commit 80c09dd

Browse files
makoru-hikagewouterj
authored andcommitted
Error in CSRF example code snippet
Something's wrong when I tried this code: `$formFactory = Forms::createFormFactoryBuilder()` ` // ...` ` ->addExtension(new CsrfExtension($csrfStorage))` ` ->getFormFactory();` Constructing a `CsrfExtension` requires a `CsrfTokenManagerInterface` as an argument (see symfony/form/Extension/Csrf/CsrfExtension.php, line 24). The `$csrfStorage` in `addExtension(new CsrfExtension($csrfStorage)`, has a class that implements `TokenStorageInterface` (see symfony/security-csrf/TokenStorage/SessionStorageToken.php, line 22). So I replaced it with `$csrfManager` that has class that implement `CsrfTokenManagerInterface`. (see symfony/security-csrf/CsrfTokenManager.php, line 24)
1 parent 0e9c462 commit 80c09dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

components/form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The following snippet adds CSRF protection to the form factory::
137137

138138
$formFactory = Forms::createFormFactoryBuilder()
139139
// ...
140-
->addExtension(new CsrfExtension($csrfStorage))
140+
->addExtension(new CsrfExtension($csrfManager))
141141
->getFormFactory();
142142

143143
Internally, this extension will automatically add a hidden field to every

0 commit comments

Comments
 (0)