8000 [Form] Fix #11694 - Enforce RepeatedType options value type check · symfony/symfony@b312a00 · GitHub
[go: up one dir, main page]

Skip to content

Commit b312a00

Browse files
committed
[Form] Fix #11694 - Enforce RepeatedType options value type check
1 parent beca900 commit b312a00

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
5555
'second_name' => 'second',
5656
'error_bubbling' => false,
5757
));
58+
59+
$resolver->setAllowedTypes(array(
60+
'options' => 'array',
61+
'first_options' => 'array',
62+
'second_options' => 'array',
63+
));
5864
}
5965

6066
/**

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,39 @@ public function testSetRequired()
7272
$this->assertFalse($form['second']->isRequired());
7373
}
7474

75+
/**
76+
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
77+
*/
78+
public function testSetInvalidOptions()
79+
{
80+
$this->factory->create('repeated', null, array(
81+
'type' => 'text',
82+
'options' => 'bad value',
83+
));
84+
}
85+
86+
/**
87+
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
88+
*/
89+
public function testSetInvalidFirstOptions()
90+
{
91+
$this->factory->create('repeated', null, array(
92+
'type' => 'text',
93+
'first_options' => 'bad value',
94+
));
95+
}
96+
97+
/**
98+
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
99+
*/
100+
public function testSetInvalidSecondOptions()
101+
{
102+
$this->factory->create('repeated', null, array(
103+
'type' => 'text',
104+
'second_options' => 'bad value',
105+
));
106+
}
107+
75108
public function testSetErrorBubblingToTrue()
76109
{
77110
$form = $this->factory->create('repeated', null, array(

0 commit comments

Comments
 (0)
0