@@ -1779,4 +1779,32 @@ public function testSubmitNullMultipleUsesDefaultEmptyData()
1779
1779
$ this ->assertEquals ($ collection , $ form ->getNormData ());
1780
1780
$ this ->assertEquals ($ collection , $ form ->getData ());
1781
1781
}
1782
+
1783
+ public function testWithSameLoaderAndDifferentChoiceValueCallbacks ()
1784
+ {
1785
+ $ entity1 = new SingleIntIdEntity (1 , 'Foo ' );
1786
+ $ entity2 = new SingleIntIdEntity (2 , 'Bar ' );
1787
+ $ this ->persist ([$ entity1 , $ entity2 ]);
1788
+
1789
+ $ view = $ this ->factory ->create (FormTypeTest::TESTED_TYPE )
1790
+ ->add ('entity_one ' , self ::TESTED_TYPE , [
1791
+ 'em ' => 'default ' ,
1792
+ 'class ' => self ::SINGLE_IDENT_CLASS ,
1793
+ ])
1794
+ ->add ('entity_two ' , self ::TESTED_TYPE , [
1795
+ 'em ' => 'default ' ,
1796
+ 'class ' => self ::SINGLE_IDENT_CLASS ,
1797
+ 'choice_value ' => function ($ choice ) {
1798
+ return $ choice ? $ choice ->name : '' ;
1799
+ },
1800
+ ])
1801
+ ->createView ()
1802
+ ;
1803
+
1804
+ $ this ->assertSame ('1 ' , $ view ['entity_one ' ]->vars ['choices ' ][1 ]->value );
1805
+ $ this ->assertSame ('2 ' , $ view ['entity_one ' ]->vars ['choices ' ][2 ]->value );
1806
+
1807
+ $ this ->assertSame ('Foo ' , $ view ['entity_two ' ]->vars ['choices ' ]['Foo ' ]->value );
1808
+ $ this ->assertSame ('Bar ' , $ view ['entity_two ' ]->vars ['choices ' ]['Bar ' ]->value );
1809
+ }
1782
1810
}
0 commit comments