tklustig
(Kipp Thomas)
June 14, 2017, 7:26am
1
Hi guys,
I created a checkbox using following code:
<?= $form->field($model,'rememberMe')->checkBox() ?>
Unfortunately, I don’t know how to evaluate, whether Checkbox has been checked, or not. Following Code
if ($model->rememberMe ==1) echo "Checkbox is activated";
else echo "Checkbox is not activated";
always prints out ‘Checkbox is not activated’. Any ideas, how to fix that?
tri
(tri - Tommy Riboe)
June 14, 2017, 7:24pm
2
Use ActiveForm->ActiveField?
Or the value of checked, IIRC
tklustig:
Hi guys,
I created a checkbox using following code:
<?= $form->field($model,'rememberMe')->checkBox() ?>
Unfortunately, I don’t know how to evaluate, whether Checkbox has been checked, or not. Following Code
if ($model->rememberMe ==1) echo "Checkbox is activated";
else echo "Checkbox is not activated";
always prints out ‘Checkbox is not activated’. Any ideas, how to fix that?
Check if the attribute ‘rememberMe’ is actually part of your rules and that you probably load the input values submitted. Then you can safely evaluate vs the value of the checkbox
tklustig
(Kipp Thomas)
June 16, 2017, 11:17am
4
Well, rememberMe was not part of my rules!
Now, it is, and it works well.Thx a lot for your help!
return [.....],['rememberMe', 'boolean']];