bug #10808 [DomCrawler] Empty select with attribute name="foo[]" bug fix (darles)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #10808).
Discussion
----------
[DomCrawler] Empty select with attribute name="foo[]" bug fix
If you have a select with attribute name="foo[]", and you submit your form, http_build_query returns empty string as a result. In this case you get a form extra field validation error, because your field "foo" converts to
'' => bool(false)
Commits
-------
15f081d
Empty select with attribute name="foo[]" bug fix
This commit is contained in:
commit
297d6501d7
@ -146,9 +146,11 @@ class Form extends Link implements \ArrayAccess
|
|||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->getValues() as $name => $value) {
|
foreach ($this->getValues() as $name => $value) {
|
||||||
$qs = http_build_query(array($name => $value), '', '&');
|
$qs = http_build_query(array($name => $value), '', '&');
|
||||||
parse_str($qs, $expandedValue);
|
if(!empty($qs)) {
|
||||||
$varName = substr($name, 0, strlen(key($expandedValue)));
|
parse_str($qs, $expandedValue);
|
||||||
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
$varName = substr($name, 0, strlen(key($expandedValue)));
|
||||||
|
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
@ -169,9 +171,11 @@ class Form extends Link implements \ArrayAccess
|
|||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->getFiles() as $name => $value) {
|
foreach ($this->getFiles() as $name => $value) {
|
||||||
$qs = http_build_query(array($name => $value), '', '&');
|
$qs = http_build_query(array($name => $value), '', '&');
|
||||||
parse_str($qs, $expandedValue);
|
if(!empty($qs)) {
|
||||||
$varName = substr($name, 0, strlen(key($expandedValue)));
|
parse_str($qs, $expandedValue);
|
||||||
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
$varName = substr($name, 0, strlen(key($expandedValue)));
|
||||||
|
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
|
Reference in New Issue
Block a user