Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4b5d63

Browse files
HeahDudefabpot
authored andcommitted
[Form]fix#15544 when a collection type attribute "required" is false, "prototype" should too
1 parent423f83f commitb4b5d63

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

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

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

196196
$this->assertSame('__test__label__',$form->createView()->vars['prototype']->vars['label']);
197197
}
198+
199+
publicfunctiontestPrototypeDefaultRequired()
200+
{
201+
$form =$this->factory->create('collection',array(),array(
202+
'type' =>'file',
203+
'allow_add' =>true,
204+
'prototype' =>true,
205+
'prototype_name' =>'__test__',
206+
));
207+
208+
$this->assertTrue($form->createView()->vars['prototype']->vars['required']);
209+
}
210+
211+
publicfunctiontestPrototypeSetNotRequired()
212+
{
213+
$form =$this->factory->create('collection',array(),array(
214+
'type' =>'file',
215+
'allow_add' =>true,
216+
'prototype' =>true,
217+
'prototype_name' =>'__test__',
218+
'required' =>false,
219+
));
220+
221+
$this->assertFalse($form->createView()->vars['required'],'collection is not required');
222+
$this->assertFalse($form->createView()->vars['prototype']->vars['required'],'"prototype" should not be required');
223+
}
198224
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp