How to mark checkboxes as checked in checkboxList

If i have simple checkbox list as this one


<?= $form->field($model, 'country')->checkboxList(['FR'=>'France', 'DE'=>'Germany', 'EN'=>'English']) ?>

How can i mark some of them as checked by default in my form ? For example, i want to mark France and Germany as checked. Any help please ?

Just set attribute that you want to be checked at start.




<?php $model->country = 'DE'; ?>

<?= $form->field($model, 'country')->checkboxList(['FR'=>'France', 'DE'=>'Germany', 'EN'=>'English']) ?>



1 Like

Thank you very much!