Reputation: 468
How can I render the checkbox unchecked by default?. I try this.
<?=$form->field($model, 'rememberMe', ['template' => "<div>{input}</div>\n<div>{error}</div>"])->checkbox(['checked'=>false])?>
But no way. It allways appends checked="checked" to the html. I need the checkbox to be unchecked for the first time.
Upvotes: 3
Views: 3288
Reputation: 21
This is very useful. only need to set true or false. For example :-
$model->"CHECKBOX NAME" as true or false
Simply
Upvotes: 2
Reputation: 133360
Try using value = false
<?=$form->field($model, 'rememberMe',
['template' => "<div>{input}</div>\n<div>{error}</div>"])->
checkbox(['value' => false])?>
or (simply) assign $model->rememberMe = false;
Upvotes: 3