bug #23254 [Form][TwigBridge] render hidden _method field in form_rest() (xabbuh)
This PR was merged into the 2.7 branch.
Discussion
----------
[Form][TwigBridge] render hidden _method field in form_rest()
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #14261
| License | MIT
| Doc PR |
Commits
-------
0ee3f57533
render hidden _method field in form_rest()
This commit is contained in:
commit
7cc97b6e0b
@ -262,6 +262,7 @@
|
|||||||
{%- endblock form -%}
|
{%- endblock form -%}
|
||||||
|
|
||||||
{%- block form_start -%}
|
{%- block form_start -%}
|
||||||
|
{%- do form.setMethodRendered() -%}
|
||||||
{% set method = method|upper %}
|
{% set method = method|upper %}
|
||||||
{%- if method in ["GET", "POST"] -%}
|
{%- if method in ["GET", "POST"] -%}
|
||||||
{% set form_method = method %}
|
{% set form_method = method %}
|
||||||
@ -301,6 +302,20 @@
|
|||||||
{{- form_row(child) -}}
|
{{- form_row(child) -}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
{% if not form.methodRendered %}
|
||||||
|
{%- do form.setMethodRendered() -%}
|
||||||
|
{% set method = method|upper %}
|
||||||
|
{%- if method in ["GET", "POST"] -%}
|
||||||
|
{% set form_method = method %}
|
||||||
|
{%- else -%}
|
||||||
|
{% set form_method = "POST" %}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- if form_method != method -%}
|
||||||
|
<input type="hidden" name="_method" value="{{ method }}" />
|
||||||
|
{%- endif -%}
|
||||||
|
{% endif %}
|
||||||
{% endblock form_rest %}
|
{% endblock form_rest %}
|
||||||
|
|
||||||
{# Support #}
|
{# Support #}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~2.7",
|
"symfony/asset": "~2.7",
|
||||||
"symfony/finder": "~2.3",
|
"symfony/finder": "~2.3",
|
||||||
"symfony/form": "~2.7.26|^2.8.19",
|
"symfony/form": "~2.7.30|^2.8.23",
|
||||||
"symfony/http-kernel": "~2.3",
|
"symfony/http-kernel": "~2.3",
|
||||||
"symfony/intl": "~2.3",
|
"symfony/intl": "~2.3",
|
||||||
"symfony/routing": "~2.2",
|
"symfony/routing": "~2.2",
|
||||||
@ -36,6 +36,9 @@
|
|||||||
"symfony/var-dumper": "~2.7.16|^2.8.9",
|
"symfony/var-dumper": "~2.7.16|^2.8.9",
|
||||||
"symfony/expression-language": "~2.4"
|
"symfony/expression-language": "~2.4"
|
||||||
},
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/form": "<2.7.30|~2.8,<2.8.23"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/finder": "",
|
"symfony/finder": "",
|
||||||
"symfony/asset": "For using the AssetExtension",
|
"symfony/asset": "For using the AssetExtension",
|
||||||
|
@ -53,6 +53,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
private $rendered = false;
|
private $rendered = false;
|
||||||
|
|
||||||
|
private $methodRendered = false;
|
||||||
|
|
||||||
public function __construct(FormView $parent = null)
|
public function __construct(FormView $parent = null)
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
@ -90,6 +92,19 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isMethodRendered()
|
||||||
|
{
|
||||||
|
return $this->methodRendered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMethodRendered()
|
||||||
|
{
|
||||||
|
$this->methodRendered = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a child by name (implements \ArrayAccess).
|
* Returns a child by name (implements \ArrayAccess).
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user