diff --git a/Form/Type/PolyCollectionType.php b/Form/Type/PolyCollectionType.php index 7790fed..7b457d1 100644 --- a/Form/Type/PolyCollectionType.php +++ b/Form/Type/PolyCollectionType.php @@ -71,6 +71,7 @@ protected function buildPrototypes(FormBuilderInterface $builder, array $options { $prototypes = array(); $useTypesOptions = !empty($options['types_options']); + $useTypesPrototypeData = !empty($options['types_prototype_data']); foreach ($options['types'] as $type) { if ($type instanceof FormTypeInterface) { @@ -85,6 +86,12 @@ protected function buildPrototypes(FormBuilderInterface $builder, array $options } } + if ($useTypesPrototypeData) { + if (isset($options['types_prototype_data'][$type])) { + $typeOptions['data'] = $options['types_prototype_data'][$type]; + } + } + $prototype = $this->buildPrototype( $builder, $options['prototype_name'], @@ -184,6 +191,7 @@ public function configureOptions(OptionsResolver $resolver) 'allow_add' => false, 'allow_delete' => false, 'prototype' => true, + 'types_prototype_data' => [], 'prototype_name' => '__name__', 'type_name' => '_type', 'options' => [],