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
Post a Comment