Skip to content

Commit 1beb526

Browse files
committed
[#2969][#2974] Small tweaks to handleRequest in Form component
Added some additional details about what's going on behind the scenes
1 parent f90e038 commit 1beb526

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

components/form/introduction.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,19 @@ Request Handling
7070
The ``handleRequest()`` method was added in Symfony 2.3.
7171

7272
To process form data, you'll need to call the :method:`Symfony\\Component\\Form\\Form::handleRequest`
73-
method.
73+
method::
7474

75-
To optionally integrate the HttpFoundation component, add the
76-
:class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationExtension`
77-
to your form factory::
75+
$form->handleRequest();
76+
77+
Behind the scenes, this uses a :class:`Symfony\\Component\\Form\\NativeRequestHandler`
78+
object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or
79+
``$_GET``) based on the HTTP method configured on the form (POST is default).
80+
81+
.. sidebar:: Integration with the HttpFoundation Component
82+
83+
If you use the HttpFoundation component, then you should add the
84+
:class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationExtension`
85+
to your form factory::
7886

7987
use Symfony\Component\Form\Forms;
8088
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
@@ -83,13 +91,15 @@ to your form factory::
8391
->addExtension(new HttpFoundationExtension())
8492
->getFormFactory();
8593

86-
Now, when you process a form, you can pass the :class:`Symfony\\Component\\HttpFoundation\\Request`
87-
object to :method:`Symfony\\Component\\Form\\Form::handleRequest`.
94+
Now, when you process a form, you can pass the :class:`Symfony\\Component\\HttpFoundation\\Request`
95+
object to :method:`Symfony\\Component\\Form\\Form::handleRequest`::
8896

89-
.. note::
97+
$form->handleRequest($request);
98+
99+
.. note::
90100

91-
For more information about the HttpFoundation component or how to
92-
install it, see :doc:`/components/http_foundation/introduction`.
101+
For more information about the HttpFoundation component or how to
102+
install it, see :doc:`/components/http_foundation/introduction`.
93103

94104
CSRF Protection
95105
~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy