[Form] Remove choice or choice_list requirement as the following conditions already check enough and this condition prevents empty select forms (populated by ajax for example)
This commit is contained in:
parent
8a1fe40829
commit
431460f6ff
4
src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Normal file → Executable file
4
src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Normal file → Executable file
@ -31,10 +31,6 @@ class ChoiceType extends AbstractType
|
||||
*/
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
if (!$options['choices'] && !$options['choice_list']) {
|
||||
throw new FormException('Either the option "choices" or "choice_list" is required');
|
||||
}
|
||||
|
||||
if ($options['choice_list'] && !$options['choice_list'] instanceof ChoiceListInterface) {
|
||||
throw new FormException('The "choice_list" must be an instance of "Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface".');
|
||||
}
|
||||
|
8
tests/Symfony/Tests/Component/Form/Extension/Core/Type/ChoiceTypeTest.php
Normal file → Executable file
8
tests/Symfony/Tests/Component/Form/Extension/Core/Type/ChoiceTypeTest.php
Normal file → Executable file
@ -303,14 +303,6 @@ class ChoiceTypeTest extends TypeTestCase
|
||||
$this->assertEquals(array('0', '1'), $form->getClientData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\FormException
|
||||
*/
|
||||
public function testRequiresChoicesOrChoiceListOption()
|
||||
{
|
||||
$this->factory->create('choice', 'name');
|
||||
}
|
||||
|
||||
public function testPassRequiredToView()
|
||||
{
|
||||
$form = $this->factory->create('choice', null, array(
|
||||
|
Reference in New Issue
Block a user