$form = $this->beginWidget('CActiveForm', array( 'id'=>'my-form', 'enableAjaxValidation'=>false, ))); echo $form->checkBoxList($model, 'colors', array( 'red' => 'Red', 'blue' => 'Blue', 'green' => 'Green', 'yellow' => 'Yellow', 'purple' => 'Purple' )); $this->endWidget();
echo CHtml::activeCheckBoxList($model, 'selectedItems', CHtml::listData($items, 'id', 'name'));In this example, activeCheckBoxList is used to display a list of checkbox inputs that correspond with a "selectedItems" attribute in the model. The list of checkboxes is populated by calling the CHtml method 'listData' which converts an array of ActiveRecord models into a data array that can be used in various CHtml inputs. Overall, CHtml activeCheckBoxList is a useful tool for creating a list of checkboxes that correspond with an attribute in an ActiveRecord model. It's implemented in the CHtml library of the Yii framework.