Be sure that both fields have same value for required option in RepeatedType
This commit is contained in:
parent
0679220b45
commit
f8a6a4b1e5
@ -22,6 +22,10 @@ class RepeatedType extends AbstractType
|
||||
*/
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
// Overwrite required option for child fields
|
||||
$options['first_options']['required'] = $options['options']['required'];
|
||||
$options['second_options']['required'] = $options['options']['required'];
|
||||
|
||||
$builder
|
||||
->appendClientTransformer(new ValueToDuplicatesTransformer(array(
|
||||
$options['first_name'],
|
||||
|
@ -59,7 +59,7 @@ class RepeatedTypeTest extends TypeTestCase
|
||||
|
||||
$this->assertEquals('Test', $form['first']->getAttribute('label'));
|
||||
$this->assertEquals('Test2', $form['second']->getAttribute('label'));
|
||||
$this->assertFalse($form['first']->isRequired());
|
||||
$this->assertTrue($form['first']->isRequired());
|
||||
$this->assertTrue($form['second']->isRequired());
|
||||
}
|
||||
|
||||
@ -67,14 +67,13 @@ class RepeatedTypeTest extends TypeTestCase
|
||||
{
|
||||
$form = $this->factory->create('repeated', null, array(
|
||||
'type' => 'field',
|
||||
'options' => array('label' => 'Label'),
|
||||
'first_options' => array('required' => false),
|
||||
'options' => array('label' => 'Label'),
|
||||
'second_options' => array('label' => 'Second label')
|
||||
));
|
||||
|
||||
$this->assertEquals('Label', $form['first']->getAttribute('label'));
|
||||
$this->assertEquals('Second label', $form['second']->getAttribute('label'));
|
||||
$this->assertFalse($form['first']->isRequired());
|
||||
$this->assertTrue($form['first']->isRequired());
|
||||
$this->assertTrue($form['second']->isRequired());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user