Skip to content

Commit

Permalink
[Form] Fix "prototype_data" option creating duplicates instead of new…
Browse files Browse the repository at this point in the history
… lines
  • Loading branch information
Thorry84 authored and nicolas-grekas committed Apr 19, 2023
1 parent e325cdd commit a123512
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Extension/Core/Type/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class CollectionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$prototypeOptions = null;
$resizePrototypeOptions = null;
if ($options['allow_add'] && $options['prototype']) {
$resizePrototypeOptions = array_replace($options['entry_options'], $options['prototype_options']);
$prototypeOptions = array_replace([
'required' => $options['required'],
'label' => $options['prototype_name'].'label__',
], array_replace($options['entry_options'], $options['prototype_options']));
], $resizePrototypeOptions);

if (null !== $options['prototype_data']) {
$prototypeOptions['data'] = $options['prototype_data'];
Expand All @@ -44,7 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$options['allow_add'],
$options['allow_delete'],
$options['delete_empty'],
$prototypeOptions
$resizePrototypeOptions
);

$builder->addEventSubscriber($resizeListener);
Expand Down

0 comments on commit a123512

Please sign in to comment.