Skip to content

Commit 51fdaa8

Browse files
committed
document the requests constructor argument of the RequestStack class
1 parent f1c7127 commit 51fdaa8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/form.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ The following snippet adds CSRF protection to the form factory::
123123
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
124124

125125
// creates a RequestStack object using the current request
126-
$requestStack = new RequestStack();
127-
$requestStack->push($request);
126+
$requestStack = new RequestStack([$request]);
128127

129128
$csrfGenerator = new UriSafeTokenGenerator();
130129
$csrfStorage = new SessionTokenStorage($requestStack);
@@ -135,6 +134,11 @@ The following snippet adds CSRF protection to the form factory::
135134
->addExtension(new CsrfExtension($csrfManager))
136135
->getFormFactory();
137136

137+
.. versionadded:: 7.2
138+
139+
Support for passing requests to the constructor of the ``RequestStack``
140+
class was introduced in Symfony 7.2.
141+
138142
Internally, this extension will automatically add a hidden field to every
139143
form (called ``_token`` by default) whose value is automatically generated by
140144
the CSRF generator and validated when binding the form.

0 commit comments

Comments
 (0)