File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
src/Symfony/Component/Form
Tests/Extension/Core/Type Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -562,6 +562,7 @@ public function submit($submittedData, $clearMissing = true)
562562
563563 foreach ($ this ->children as $ name => $ child ) {
564564 $ isSubmitted = array_key_exists ($ name , $ submittedData );
565+ $ clearMissing = $ this ->getConfig ()->getOption ('expanded ' ) ?: $ clearMissing ;
565566
566567 if ($ isSubmitted || $ clearMissing ) {
567568 $ child ->submit ($ isSubmitted ? $ submittedData [$ name ] : null , $ clearMissing );
@@ -580,8 +581,6 @@ public function submit($submittedData, $clearMissing = true)
580581 if (method_exists ($ child , 'getClickedButton ' ) && null !== $ child ->getClickedButton ()) {
581582 $ this ->clickedButton = $ child ->getClickedButton ();
582583 }
583- } elseif (!$ isSubmitted && !$ clearMissing && array_key_exists ($ name , $ submittedData )) {
584- $ child ->submit ($ submittedData [$ name ], $ clearMissing );
585584 }
586585 }
587586
Original file line number Diff line number Diff line change @@ -1934,4 +1934,23 @@ public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenExpanded()
19341934
19351935 $ this ->assertSame (array ('foo ' => 'baz ' ), $ form ->getData ());
19361936 }
1937+
1938+ public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenCollapsed ()
1939+ {
1940+ $ builder = $ this ->factory ->createBuilder ('form ' , array ('foo ' => 'bar ' ));
1941+
1942+ $ form = $ builder ->add ('foo ' , 'choice ' , array (
1943+ <
7FA0
span class=pl-s>'choices ' => array (
1944+ 'bar ' => 'BAR ' ,
1945+ 'baz ' => 'BAZ ' ,
1946+ ),
1947+ ))
1948+ ->getForm ();
1949+
1950+ $ this ->assertSame (array ('foo ' => 'bar ' ), $ form ->getData ());
1951+
1952+ $ form ->submit (array ('foo ' => 'baz ' ), false );
1953+
1954+ $ this ->assertSame (array ('foo ' => 'baz ' ), $ form ->getData ());
1955+ }
19371956}
You can’t perform that action at this time.
0 commit comments