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

Conversation

yapro
Copy link

@yapro yapro commented Dec 13, 2015

I got error: 'Expected argument of type "null", "Symfony\Component\HttpFoundation\Request" given'

https://github.com/symfony/form/blob/master/NativeRequestHandler.php#L55

"class": "'Symfony\\Component\\Form\\Exception\\UnexpectedTypeException'",
"file": "'\/home\/www\/vendor\/symfony\/form\/NativeRequestHandler.php'",
"line": "56",
"level": 500,
"level_name": "CRITICAL",

#0 /vendor/symfony/form/Form.php(499): Symfony\Component\Form\NativeRequestHandler->handleRequest(Object(Symfony\Component\Form\Form), Object(Symfony\Component\HttpFoundation\Request))
#1 /application/controllers/product.php(335): Symfony\Component\Form\Form->handleRequest(Object(Symfony\Component\HttpFoundation\Request))

…\\HttpFoundation\\Request\" given

https://github.com/symfony/form/blob/master/NativeRequestHandler.php#L55

    "class": "'Symfony\\Component\\Form\\Exception\\UnexpectedTypeException'",
    "file": "'\/home\/www\/datravel\/datravel-website\/vendor\/symfony\/form\/NativeRequestHandler.php'",
    "line": "56",
    "level": 500,
    "level_name": "CRITICAL",

#0 /vendor/symfony/form/Form.php(499): Symfony\Component\Form\NativeRequestHandler->handleRequest(Object(Symfony\Component\Form\Form), Object(Symfony\Component\HttpFoundation\Request))
#1 /application/controllers/product.php(335): Symfony\Component\Form\Form->handleRequest(Object(Symfony\Component\HttpFoundation\Request))
@@ -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.

@ogizanagi
Copy link
Contributor

@yapro : I think there is a misunderstanding.
Do you use the Symfony Framework, or do you use the form component standalone ?
Did you configure the HttpFoundation integration properly if you're using the HttpFoundation component with the standalone form component ?

@yapro
Copy link
Author

yapro commented Dec 14, 2015

Thx, I use the form component as standalone.

@yapro yapro closed this Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants