From 249ca2541ce9c5c8fd8ab40ec202f2f2d8e69296 Mon Sep 17 00:00:00 2001 From: Max McMahon Date: Fri, 16 Feb 2018 11:30:52 -0500 Subject: [PATCH] Add support for prototype_data --- Form/Type/PolyCollectionType.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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' => [],