File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
src/Symfony/Component/Form Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1313
1414use Symfony \Component \Form \Exception \FormException ;
1515use Symfony \Component \Form \Exception \AlreadyBoundException ;
16- use Symfony \Component \Form \Exception \UnexpectedTypeException ;
1716use Symfony \Component \Form \Exception \TransformationFailedException ;
1817use Symfony \Component \Form \Util \FormUtil ;
1918use Symfony \Component \Form \Util \PropertyPath ;
@@ -533,10 +532,6 @@ public function bind($submittedData)
533532 // (think of empty collection forms)
534533 if ($ this ->config ->getCompound ()) {
535534 if (!is_array ($ submittedData )) {
536- if (!FormUtil::isEmpty ($ submittedData )) {
537- throw new UnexpectedTypeException ($ submittedData , 'array ' );
538- }
539-
540535 $ submittedData = array ();
541536 }
542537
Original file line number Diff line number Diff line change @@ -779,6 +779,25 @@ public function testSetDataCannotInvokeItself()
779779 $ form ->setData ('foo ' );
780780 }
781781
782+ public function testBindingWrongDataIsIgnored ()
783+ {
784+ $ test = $ this ;
785+
786+ $ child = $ this ->getBuilder ('child ' , $ this ->dispatcher );
787+ $ child ->addEventListener (FormEvents::PRE_BIND , function (FormEvent $ event ) use ($ test ) {
788+ // child form doesn't receive the wrong data that is bound on parent
789+ $ test ->assertNull ($ event ->getData ());
790+ });
791+
792+ $ parent = $ this ->getBuilder ('parent ' , new EventDispatcher ())
793+ ->setCompound (true )
794+ ->setDataMapper ($ this ->getDataMapper ())
795+ ->add ($ child )
796+ ->getForm ();
797+
798+ $ parent ->bind ('not-an-array ' );
799+ }
800+
782801 protected function createForm ()
783802 {
784803 return $ this ->getBuilder ()->getForm ();
You can’t perform that action at this time.
0 commit comments