Answer the question
In order to leave comments, you need to log in
How to make checkbox checked in Yii2?
Hello
<?=$edit_form->field($model, 'serv1')->checkbox([ 'value' => '1'])->label('');?>
<input type="checkbox" name="serv1" value="1" checked>
Answer the question
In order to leave comments, you need to log in
The guys figured out the need for the 'checked ' attribute with an extra space
<?=$edit_form->field($model, 'serv1')->checkbox([ 'value' => '1', 'checked ' => true])-> label('');?>
If the checkbox is NOT needed by default:
...
<?php
$page->text = 'я принимаю пользовательское соглашение';
?>
...
<?=$form->field($model, 'serv1')->checkbox(['uncheck' => $page->text, 'value' => $page->text, 'label' => '$page->text]); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question