[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:
Benjamin Eberlei 2011-07-05 15:19:46 +02:00
parent 8a1fe40829
commit 431460f6ff
2 changed files with 0 additions and 12 deletions

View 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".');
}

View 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(