Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got error: Expected argument of type \"null\", \"Symfony\\Component… #6007

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or
Now, when you process a form, you can pass the :class:`Symfony\\Component\\HttpFoundation\\Request`
object to :method:`Symfony\\Component\\Form\\Form::handleRequest`::

$form->handleRequest($request);
$form->handleRequest();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows the integration with the HttpFoundation component. It registers a HttpFoundationRequestHandler which expects a Request instance.


.. note::

Expand Down Expand Up @@ -556,7 +556,7 @@ method:

$request = Request::createFromGlobals();

$form->handleRequest($request);
$form->handleRequest();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a Request instance is created in this example, I guess the fix should be to add the HttpFoundation integration before those lines and revert this change:

use Symfony\Component\Form\Forms;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;

$formFactory = Forms::createFormFactoryBuilder()
    ->addExtension(new HttpFoundationExtension())
    ->getFormFactory();

This will add the HttpFoundationRequestHandler, instead of using the base NativeRequestHandler.


if ($form->isValid()) {
$data = $form->getData();
Expand All @@ -582,7 +582,7 @@ method:
->add('dueDate', 'date')
->getForm();

$form->handleRequest($request);
$form->handleRequest();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted IMO, as this example shows the usage of the form component inside the Symfony framework. The HttpFoundationRequestHandler is registered by default.


if ($form->isValid()) {
$data = $form->getData();
Expand Down