8000 [Form] Empty root form name fails with PUT method · Issue #19017 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Empty root form name fails with PUT method #19017

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

Closed
jbenezech opened this issue Jun 10, 2016 · 2 comments
Closed

[Form] Empty root form name fails with PUT method #19017

jbenezech opened this issue Jun 10, 2016 · 2 comments

Comments

@jbenezech
Copy link

A form created like this will result in an extra data error

        $form = $this->get('form.factory')  
            ->createNamed('',  
            ArticleType::class,  
            $article,  
            [  
                'action' => $this->generateUrl(  
                    'article_update',  
                    [  
                        'article' => $article->getId()  
                    ]  
                ),  
                'method' => 'PUT',  
            ]  
        );  

It seems that the RequestHandler will submit the form with all request parameters in case of an empty form name (which includes the hidden _method field)

if ('' === $name) {
    $params = $request->request->all();
    $files = $request->files->all();
}

The submit method of the Form doesn't seem to do any particular check for that special parameter.

A workaround is to set allow_extra_fields to true in the form

@javiereguiluz javiereguiluz changed the title Empty root form name fails with PUT method [Form] Empty root form name fails with PUT method Jun 10, 2016
@BboyKeen
Copy link

I can confirm. I just lost a few hours on this one today.
If someone can orient me, I'll be glad to make a PR

B66C

@HeahDude
Copy link
Contributor

I can't find an easy fix for this, since the _method field is the HttpFoundation responsibility.

Maybe it could acceptable to "remove" the parameter instead of just "getting" it here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L1215.
Otherwise we would need to add a new form listener to do the job :/.

nicolas-grekas added a commit that referenced this issue Feb 8, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

[Form] ignore _method forms in NativeRequestHandler

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19017
| License       | MIT
| Doc PR        |

Commits
-------

bc4b091 ignore _method forms in NativeRequestHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0