Skip to content

Commit 3d95d1c

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [Form] fix #15544 when a collection type attribute "required" is false, "prototype" should too updated validators.bg.xlf [Security] Enable bcrypt validation and result length tests on all PHP versions [Security] Verify if a password encoded with bcrypt is no longer than 72 characters [Console] Avoid extra blank lines when rendering exceptions [Yaml] do not remove "comments" in scalar blocks
2 parents 9ac6585 + f87ebd8 commit 3d95d1c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Extension/Core/Type/CollectionType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2828
{
2929
if ($options['allow_add'] && $options['prototype']) {
3030
$prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array(
31+
'required' => $options['required'],
3132
'label' => $options['prototype_name'].'label__',
3233
), $options['options']));
3334
$builder->setAttribute('prototype', $prototype->getForm());

Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,30 @@ public function testPrototypeDefaultLabel()
274274

275275
$this->assertSame('__test__label__', $form->createView()->vars['prototype']->vars['label']);
276276
}
277+
278+
public function testPrototypeDefaultRequired()
279+
{
280+
$form = $this->factory->create('collection', array(), array(
281+
'type' => 'file',
282+
'allow_add' => true,
283+
'prototype' => true,
284+
'prototype_name' => '__test__',
285+
));
286+
287+
$this->assertTrue($form->createView()->vars['prototype']->vars['required']);
288+
}
289+
290+
public function testPrototypeSetNotRequired()
291+
{
292+
$form = $this->factory->create('collection', array(), array(
293+
'type' => 'file',
294+
'allow_add' => true,
295+
'prototype' => true,
296+
'prototype_name' => '__test__',
297+
'required' => false,
298+
));
299+
300+
$this->assertFalse($form->createView()->vars['required'], 'collection is not required');
301+
$this->assertFalse($form->createView()->vars['prototype']->vars['required'], '"prototype" should not be required');
302+
}
277303
}

0 commit comments

Comments
 (0)