Skip to content

Commit

Permalink
document the requests constructor argument of the RequestStack class
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Aug 20, 2024
1 parent f1c7127 commit 51fdaa8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ The following snippet adds CSRF protection to the form factory::
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;

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

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

.. versionadded:: 7.2

Support for passing requests to the constructor of the ``RequestStack``
class was introduced in Symfony 7.2.

Internally, this extension will automatically add a hidden field to every
form (called ``_token`` by default) whose value is automatically generated by
the CSRF generator and validated when binding the form.
Expand Down

0 comments on commit 51fdaa8

Please sign in to comment.