activeCheckboxList - how to make all checked by default?

I am creating a list of checkboxes by using the following code:




CHtml::activeCheckboxList(CallDestination::model(), 'id', CHtml::listData(CallDestination::model()->findAll(), 'id', 'name'));



What I need is for each checkbox to be selected by default, but I can’t seem to figure out how to do that. Any advice?

Try to set, as second parameter, the array of selected values like


CHtml::activeCheckboxList(CallDestination::model(), array(33,55), CHtml::listData(CallDestination::model()->findAll(), 'id', 'name'));

#activeCheckBoxList

second attribute of CHtml::activeCheckboxList is name of model attribute so it will be like it was id. but you need to define id values of module.


$model = CallDestination::model();

$model->id = array(1,2,3,4);