From 35fe06798e4f545087b1178467c2bab53891baa3 Mon Sep 17 00:00:00 2001 From: fmarchalemisys <30406081+fmarchalemisys@users.noreply.github.com> Date: Mon, 24 Jul 2017 16:01:47 +0200 Subject: [PATCH 1/2] [Form][TwigBridge] Don't render _method in form_rest() for a child form Always generating the hidden _method breaks forms using the POST method when they have children using the PUT method. The _method generated for a child form overrides the parent method and the form fails to validate. The hidden _method must only be generated if the form is the top most form. See issue #23254 --- .../Bridge/Twig/Resources/views/Form/form_div_layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index 0a52cc5110c82..2b21ed2fe6a36 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -303,7 +303,7 @@ {% endif %} {%- endfor %} - {% if not form.methodRendered %} + {% if not form.methodRendered and form.parent is empty %} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} From be4eb8264b7e6162af32aaea6ce059d78592401f Mon Sep 17 00:00:00 2001 From: fmarchalemisys <30406081+fmarchalemisys@users.noreply.github.com> Date: Tue, 25 Jul 2017 08:16:24 +0200 Subject: [PATCH 2/2] [Form][TwigBridge] Use null to check for top most form As requested, use "is null" instead of "is empty" to check if the form is a child or the top parent form. Only the top most form must output the hidden "_method". --- .../Bridge/Twig/Resources/views/Form/form_div_layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index 2b21ed2fe6a36..a27c81dd495ae 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -303,7 +303,7 @@ {% endif %} {%- endfor %} - {% if not form.methodRendered and form.parent is empty %} + {% if not form.methodRendered and form.parent is null %} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%}