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)
562
562
563
563
foreach ($ this ->children as $ name => $ child ) {
564
564
$ isSubmitted = array_key_exists ($ name , $ submittedData );
565
+ $ clearMissing = $ this ->getConfig ()->getOption ('expanded ' ) ?: $ clearMissing ;
565
566
566
567
if ($ isSubmitted || $ clearMissing ) {
567
568
$ child ->submit ($ isSubmitted ? $ submittedData [$ name ] : null , $ clearMissing );
@@ -580,8 +581,6 @@ public function submit($submittedData, $clearMissing = true)
580
581
if (method_exists ($ child , 'getClickedButton ' ) && null !== $ child ->getClickedButton ()) {
581
582
$ this ->clickedButton = $ child ->getClickedButton ();
582
583
}
583
- } elseif (!$ isSubmitted && !$ clearMissing && array_key_exists ($ name , $ submittedData )) {
584
- $ child ->submit ($ submittedData [$ name ], $ clearMissing );
585
584
}
586
585
}
587
586
Original file line number Diff line number Diff line change @@ -1934,4 +1934,23 @@ public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenExpanded()
1934
1934
1935
1935
$ this ->assertSame (array ('foo ' => 'baz ' ), $ form ->getData ());
1936
1936
}
1937
+
1938
+ public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenCollapsed ()
1939
+ {
1940
+ $ builder = $ this ->factory ->createBuilder ('form ' , array ('foo ' => 'bar ' ));
1941
+
1942
+ $ form = $ builder ->add ('foo ' , 'choice ' , array (
1943
+ '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
+ }
1937
1956
}
You can’t perform that action at this time.
0 commit comments