mardi 19 mars 2019

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

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?




Aucun commentaire:

Enregistrer un commentaire