mercredi 5 août 2020

How can I use checkboxType Field in Symfony formbuilder?

I am using checkboxType Field with Symfony formbuilder (https://symfony.com/doc/current/reference/forms/types/checkbox.html)

$options = [
          'attr' => array('class' => 'checkbox'),
          'data' => true,
          'mapped' => false,
          'data_class' => null,
          'required' => true,
       ];

It works well, when the value is set to TRUE. But as soon I set the value to FALSE, then the field is not listed anymore in my formData Array:

$('#form_send').on('click', function (e) {
        var form = $(this).closest('form');
        var formData = form.serializeArray();

What can I do?




Aucun commentaire:

Enregistrer un commentaire