Suppose I have the following:
Listing model:
public $selections;
// model relation - listing can have many categories
'listing_cats'=>array(self::HAS_MANY, 'ListingCategory', 'listing_id'),
ListingCategory table has fields: id, listing_id, category_id
Listing View:
<?php echo $form->checkBoxList($model, 'selections', Category::model()->getCategoriesList()); ?>
Category model:
public function getCategoriesList()
{
return CHtml::listData($this->findAll(), 'id', 'name');
}
How can I reference the ‘listing_cats’ relation to populate the checkboxlist, i.e pre-tick the selections that exist for this record?