bug #10251 [Form][2.3] Fixes empty file-inputs getting treated as extra field. (jenkoian)
This PR was squashed before being merged into the 2.3 branch (closes #10251). Discussion ---------- [Form][2.3] Fixes empty file-inputs getting treated as extra field. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8575 (https://github.com/symfony/symfony/pull/8575#issuecomment-34867485) | License | MIT Re-applies 968fe23 (PR #8575). The test for this already exists, it was just this line that got overwritten byeb9f76d5ba (diff-ca5e25b47f3ecc94cd557946aeb486c6L542)
To clarify, this is a PR into 2.3 branch - this already exists in 2.4 (and later from this PR: https://github.com/symfony/symfony/pull/9146) Commits -------8d99d75
[Form][2.3] Fixes empty file-inputs getting treated as extra field.
This commit is contained in:
commit
485efad0bb
@ -556,7 +556,7 @@ class Form implements \IteratorAggregate, FormInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->children as $name => $child) {
|
foreach ($this->children as $name => $child) {
|
||||||
if (isset($submittedData[$name]) || $clearMissing) {
|
if (array_key_exists($name, $submittedData) || $clearMissing) {
|
||||||
$child->submit(isset($submittedData[$name]) ? $submittedData[$name] : null, $clearMissing);
|
$child->submit(isset($submittedData[$name]) ? $submittedData[$name] : null, $clearMissing);
|
||||||
unset($submittedData[$name]);
|
unset($submittedData[$name]);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
$child = $factory->create('file', null, array('auto_initialize' => false));
|
$child = $factory->create('file', null, array('auto_initialize' => false));
|
||||||
|
|
||||||
$this->form->add($child);
|
$this->form->add($child);
|
||||||
$this->form->submit(array('file' => null));
|
$this->form->submit(array('file' => null), false);
|
||||||
|
|
||||||
$this->assertCount(0, $this->form->getExtraData());
|
$this->assertCount(0, $this->form->getExtraData());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user