File tree 2 files changed +19
-5
lines changed
src/Symfony/Component/Form
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Form \Exception \FormException ;
15
15
use Symfony \Component \Form \Exception \AlreadyBoundException ;
16
- use Symfony \Component \Form \Exception \UnexpectedTypeException ;
17
16
use Symfony \Component \Form \Exception \TransformationFailedException ;
18
17
use Symfony \Component \Form \Util \FormUtil ;
19
18
use Symfony \Component \Form \Util \PropertyPath ;
@@ -533,10 +532,6 @@ public function bind($submittedData)
533
532
// (think of empty collection forms)
534
533
if ($ this ->config ->getCompound ()) {
535
534
if (!is_array ($ submittedData )) {
536
- if (!FormUtil::isEmpty ($ submittedData )) {
537
- throw new UnexpectedTypeException ($ submittedData , 'array ' );
538
- }
539
-
540
535
$ submittedData = array ();
541
536
}
542
537
Original file line number Diff line number Diff line change @@ -779,6 +779,25 @@ public function testSetDataCannotInvokeItself()
779
779
$ form ->setData ('foo ' );
780
780
}
781
781
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
+
782
801
protected function createForm ()
783
802
{
784
803
return $ this ->getBuilder ()->getForm ();
You can’t perform that action at this time.
0 commit comments