diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index e03e329ff8..6dabd380e0 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -548,7 +548,7 @@ class Form implements \IteratorAggregate, FormInterface } 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); unset($submittedData[$name]); } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index 225cc93391..2b35a8fc28 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -82,6 +82,19 @@ class CompoundFormTest extends AbstractFormTest $this->assertTrue($form->isValid()); } + public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull() + { + $child = $this->getMockForm('firstName'); + + $this->form->add($child); + + $child->expects($this->once()) + ->method('submit') + ->with($this->equalTo(null)); + + $this->form->submit(array('firstName' => null), false); + } + public function testSubmitForwardsNullIfValueIsMissing() { $child = $this->getMockForm('firstName');