$fruits = array( 'apple' => 'Apple', 'banana' => 'Banana', 'cherry' => 'Cherry', 'mango' => 'Mango', ); echo CHtml::checkBoxList('fruits', array(), $fruits);
$categories = Category::model()->findAll(); $catList = CHtml::listData($categories, 'id', 'name'); echo CHtml::checkBoxList('categories', array(), $catList);This code will retrieve all the category records from the database using Yii's ActiveRecord and convert them to an associative array that can be used with checkBoxList. It will then generate a list of checkboxes for selecting one or many blog post categories.