File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
src/Symfony/Component/Form
Extension/Core/EventListener
Tests/Extension/Core/Type Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function onBindClientData(FilterDataEvent $event)
4141 $ values = (array ) $ event ->getData ();
4242 $ indices = $ this ->choiceList ->getIndicesForValues ($ values );
4343
44- $ event ->setData (array_combine ($ indices , $ values ));
44+ $ event ->setData (count ( $ indices ) > 0 ? array_combine ($ indices , $ values) : array ( ));
4545 }
4646
4747 static public function getSubscribedEvents ()
Original file line number Diff line number Diff line change @@ -399,6 +399,29 @@ public function testBindMultipleExpanded()
399399 $ this ->assertNull ($ form [4 ]->getClientData ());
400400 }
401401
402+ public function testBindMultipleExpandedEmpty ()
403+ {
404+ $ form = $ this ->factory ->create ('choice ' , null , array (
405+ 'multiple ' => true ,
406+ 'expanded ' => true ,
407+ 'choices ' => $ this ->choices ,
408+ ));
409+
410+ $ form ->bind (array ());
411+
412+ $ this ->assertSame (array (), $ form ->getData ());
413+ $ this ->assertFalse ($ form [0 ]->getData ());
414+ $ this ->assertFalse ($ form [1 ]->getData ());
415+ $ this ->assertFalse ($ form [2 ]->getData ());
416+ $ this ->assertFalse ($ form [3 ]->getData ());
417+ $ this ->assertFalse ($ form [4 ]->getData ());
418+ $ this ->assertNull ($ form [0 ]->getClientData ());
419+ $ this ->assertNull ($ form [1 ]->getClientData ());
420+ $ this ->assertNull ($ form [2 ]->getClientData ());
421+ $ this ->assertNull ($ form [3 ]->getClientData ());
422+ $ this ->assertNull ($ form [4 ]->getClientData ());
423+ }
424+
402425 public function testBindMultipleExpandedWithEmptyField ()
403426 {
404427 $ form = $ this ->factory ->create ('choice ' , null , array (
You can’t perform that action at this time.
0 commit comments