8000 [Form] Fixed label of prototype in CollectionType · symfony/symfony@6e0b03a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e0b03a

Browse files
committed
[Form] Fixed label of prototype in CollectionType
1 parent fc342d1 commit 6e0b03a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class CollectionType extends AbstractType
2626
public function buildForm(FormBuilder $builder, array $options)
2727
{
2828
if ($options['allow_add'] && $options['prototype']) {
29-
$prototype = $builder->create($options['prototype_name'], $options['type'], $options['options']);
29+
$prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array(
30+
'label' => $options['prototype_name'] . 'label__',
31+
), $options['options']));
3032
$builder->setAttribute('prototype', $prototype->getForm());
3133
}
3234

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ public function testPrototypeDefaultLabel()
192192
'type' => 'file',
193193
'allow_add' => true,
194194
'prototype' => true,
195+
'prototype_name' => '__test__',
195196
));
196197

197-
$this->assertSame('__name__', $form->createView()->get('prototype')->get('label'));
198+
$this->assertSame('__test__label__', $form->createView()->get('prototype')->get('label'));
198199
}
199200
}

0 commit comments

Comments
 (0)
0