Evaluating Checkbox

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?

Use ActiveForm->ActiveField?

Or the value of checked, IIRC

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

Well, rememberMe was not part of my rules!

Now, it is, and it works well.Thx a lot for your help!


return [.....],['rememberMe', 'boolean']];