jquery - How to set checkbox value to symfony 'true'? -


my code :

 // {{ form_row(form.termsaccept) }} generates #user_termsaccept checkbox field termsbox.attr("disabled",true); termsbox.attr("checked",true); termsbox.val('true'); // or termsbox.val(1); or termsbox.val(true); or termsbox.val(termsbox.prop('checked')); 

problem : after submit 'this value should true.' error symfony despite of fact visual state of check-box 'true'. no matter value trying set, when checking console.log() output value '1' (which default symfony check-box).

question : how set disabled check-box value "symfony's 'true'" via jquery?

when build form (controller), use :

$builder->add('termsbox', checkboxtype::class, array(     'attr' => array(         'disabled' =>'disabled',         'checked'  => 'checked',         'data'     => true,     ), )); 

instead of use jquery. or, in entity, add default value field's mapping :

protected $termsbox = true; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -