Browse Source

[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)

Benjamin Eberlei 14 năm trước cách đây
mục cha
commit
431460f6ff

+ 0 - 4
src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

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

+ 0 - 8
tests/Symfony/Tests/Component/Form/Extension/Core/Type/ChoiceTypeTest.php

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