@@ -144,21 +144,31 @@ private function parseForm($form)
144
144
$ type instanceof FormInterface || $ type instanceof ResolvedFormTypeInterface;
145
145
$ type = $ type ->getParent ()
146
146
) {
147
- if (isset ($ this ->mapTypes [$ type ->getName ()])) {
148
- $ bestType = $ this ->mapTypes [$ type ->getName ()];
147
+ $ typeName = method_exists ($ type , 'getBlockPrefix ' ) ?
148
+ $ type ->getBlockPrefix () : $ type ->getName ();
149
+
150
+ if (isset ($ this ->mapTypes [$ typeName ])) {
151
+ $ bestType = $ this ->mapTypes [$ typeName ];
149
152
$ actualType = $ bestType ;
150
- } elseif ('collection ' === $ type ->getName ()) {
151
- if (is_string ($ config ->getOption ('type ' )) && isset ($ this ->mapTypes [$ config ->getOption ('type ' )])) {
152
- $ subType = $ this ->mapTypes [$ config ->getOption ('type ' )];
153
+ } elseif ('collection ' === $ typeName ) {
154
+ $ typeOption = $ config ->getOption ('type ' );
155
+
156
+ if (is_object ($ typeOption )) {
157
+ $ typeOption = method_exists ($ typeOption , 'getBlockPrefix ' ) ?
158
+ $ typeOption ->getBlockPrefix () : $ typeOption ->getName ();
159
+ }
160
+
161
+ if (isset ($ this ->mapTypes [$ typeOption ])) {
162
+ $ subType = $ this ->mapTypes [$ typeOption ];
153
163
$ actualType = DataTypes::COLLECTION ;
154
164
$ bestType = sprintf ('array of %ss ' , $ subType );
155
165
} else {
156
166
// Embedded form collection
157
167
$ embbededType = $ config ->getOption ('type ' );
158
- $ subForm = $ this ->formFactory ->create ($ embbededType , null , $ config ->getOption ('options ' , array ()));
159
- $ children = $ this ->parseForm ($ subForm );
160
- $ actualType = DataTypes::COLLECTION ;
161
- $ subType = is_object ($ embbededType ) ? get_class ($ embbededType ) : $ embbededType ;
168
+ $ subForm = $ this ->formFactory ->create ($ embbededType , null , $ config ->getOption ('options ' , array ()));
169
+ $ children = $ this ->parseForm ($ subForm );
170
+ $ actualType = DataTypes::COLLECTION ;
171
+ $ subType = is_object ($ embbededType ) ? get_class ($ embbededType ) : $ embbededType ;
162
172
163
173
if (class_exists ($ subType )) {
164
174
$ parts = explode ('\\' , $ subType );
@@ -263,7 +273,12 @@ private function parseForm($form)
263
273
if (($ choices = $ config ->getOption ('choices ' )) && is_array ($ choices ) && count ($ choices )) {
264
274
$ parameters [$ name ]['format ' ] = json_encode ($ choices );
265
275
} elseif ($ choiceList = $ config ->getOption ('choice_list ' )) {
266
- if (('entity ' === $ config ->getType ()->getName () && false === $ this ->entityToChoice )) {
276
+ $ choiceListType = $ config ->getType ();
277
+ $ choiceListName = method_exists ($ choiceListType , 'getBlockPrefix ' ) ?
278
+ $ choiceListType ->getBlockPrefix () : $ choiceListType ->getName ();
279
+
280
+
281
+ if (('entity ' === $ choiceListName && false === $ this ->entityToChoice )) {
267
282
$ choices = array ();
268
283
} else {
269
284
// TODO: fixme
0 commit comments