diff --git a/Form.php b/Form.php index 9c6f90dbe1..ec3d5393a8 100644 --- a/Form.php +++ b/Form.php @@ -13,7 +13,6 @@ use Symfony\Component\Form\Exception\FormException; use Symfony\Component\Form\Exception\AlreadyBoundException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\Util\FormUtil; use Symfony\Component\Form\Util\PropertyPath; @@ -533,10 +532,6 @@ public function bind($submittedData) // (think of empty collection forms) if ($this->config->getCompound()) { if (!is_array($submittedData)) { - if (!FormUtil::isEmpty($submittedData)) { - throw new UnexpectedTypeException($submittedData, 'array'); - } - $submittedData = array(); } diff --git a/Tests/SimpleFormTest.php b/Tests/SimpleFormTest.php index 286e5e53ef..3a590b7509 100644 --- a/Tests/SimpleFormTest.php +++ b/Tests/SimpleFormTest.php @@ -779,6 +779,25 @@ public function testSetDataCannotInvokeItself() $form->setData('foo'); } + public function testBindingWrongDataIsIgnored() + { + $test = $this; + + $child = $this->getBuilder('child', $this->dispatcher); + $child->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use ($test) { + // child form doesn't receive the wrong data that is bound on parent + $test->assertNull($event->getData()); + }); + + $parent = $this->getBuilder('parent', new EventDispatcher()) + ->setCompound(true) + ->setDataMapper($this->getDataMapper()) + ->add($child) + ->getForm(); + + $parent->bind('not-an-array'); + } + protected function createForm() { return $this->getBuilder()->getForm();