Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9463872

Browse files
bug #50056 [Form] Fix "prototype_data" option creating duplicates instead of new lines (Thorry84)
This PR was merged into the 6.2 branch. Discussion ---------- [Form] Fix "prototype_data" option creating duplicates instead of new lines | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #49961 | License | MIT Fix for issue 49961. Changed the prototype options passed to the ResizeFormListener to prevent prototype_data from being passed to new fields. Commits ------- c204b25 [Form] Fix "prototype_data" option creating duplicates instead of new lines
2 parents 911d6a6 + c204b25 commit 9463872

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Component/Form/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)