@@ -25,17 +25,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
25
25
{
26
26
$ resizePrototypeOptions = null ;
27
27
if ($ options ['allow_add ' ] && $ options ['prototype ' ]) {
28
+ $ prototypeName = \is_callable ($ options ['prototype_name ' ]) ? $ options ['prototype_name ' ]() : $ options ['prototype_name ' ];
29
+ $ builder ->setAttribute ('resolved_prototype_name ' , $ prototypeName );
30
+
28
31
$ resizePrototypeOptions = array_replace ($ options ['entry_options ' ], $ options ['prototype_options ' ]);
29
32
$ prototypeOptions = array_replace ([
30
33
'required ' => $ options ['required ' ],
31
- 'label ' => $ options [ ' prototype_name ' ] .'label__ ' ,
34
+ 'label ' => $ prototypeName .'label__ ' ,
32
35
], $ resizePrototypeOptions );
33
36
34
37
if (null !== $ options ['prototype_data ' ]) {
35
38
$ prototypeOptions ['data ' ] = $ options ['prototype_data ' ];
36
39
}
37
40
38
- $ prototype = $ builder ->create ($ options [ ' prototype_name ' ] , $ options ['entry_type ' ], $ prototypeOptions );
41
+ $ prototype = $ builder ->create ($ prototypeName , $ options ['entry_type ' ], $ prototypeOptions );
39
42
$ builder ->setAttribute ('prototype ' , $ prototype ->getForm ());
40
43
}
41
44
@@ -121,6 +124,7 @@ public function configureOptions(OptionsResolver $resolver): void
121
124
$ resolver ->setNormalizer ('entry_options ' , $ entryOptionsNormalizer );
122
125
123
126
$ resolver ->setAllowedTypes ('delete_empty ' , ['bool ' , 'callable ' ]);
127
+ $ resolver ->setAllowedTypes ('prototype_name ' , ['string ' , 'callable ' ]);
124
128
$ resolver ->setAllowedTypes ('prototype_options ' , 'array ' );
125
129
$ resolver ->setAllowedTypes ('keep_as_list ' , ['bool ' ]);
126
130
}
0 commit comments