Skip to content

Commit a123512

Browse files
Thorry84nicolas-grekas
authored andcommitted
[Form] Fix "prototype_data" option creating duplicates instead of new lines
1 parent e325cdd commit a123512

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Extension/Core/Type/CollectionType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ class CollectionType extends AbstractType
2323
{
2424
public function buildForm(FormBuilderInterface $builder, array $options)
2525
{
26-
$prototypeOptions = null;
26+
$resizePrototypeOptions = null;
2727
if ($options['allow_add'] && $options['prototype']) {
28+
$resizePrototypeOptions = array_replace($options['entry_options'], $options['prototype_options']);
2829
$prototypeOptions = array_replace([
2930
'required' => $options['required'],
3031
'label' => $options['prototype_name'].'label__',
31-
], array_replace($options['entry_options'], $options['prototype_options']));
32+
], $resizePrototypeOptions);
3233

3334
if (null !== $options['prototype_data']) {
3435
$prototypeOptions['data'] = $options['prototype_data'];
@@ -44,7 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4445
$options['allow_add'],
4546
$options['allow_delete'],
4647
$options['delete_empty'],
47-
$prototypeOptions
48+
$resizePrototypeOptions
4849
);
4950

5051
$builder->addEventSubscriber($resizeListener);

0 commit comments

Comments
 (0)