Symfony form builder - required not working for choices field with checkboxes

时间:2019-03-19 14:54:28

标签: checkbox formbuilder symfony-2.8

So, I have symfony 2.8 project and I'm generating form field like this:

                $formBuilder->add($formId, 'choice', array(
                    'choices' => $checkboxA,
                    'choices_as_values' => true,
                    'label' => $forms->getField()->getLabel(),
                    'expanded' => true,
                    'multiple' => true,
                    'attr' => array('class' => 'checkbox_field'),
                    'required' => true
                ));

So it's a choice form element that contains multiple checkboxes. Problem is that required attribute is totally ignored. Even field is created as required if on front-end not even one checkbox is checked form passes validation successfully.

What's the problem here? Why required attribute is ignored?

0 个答案:

没有答案