I have categories with subcategories and getting list of root categories in new category creation/update form. The list is CHtml::dropDownList. Data are in CHtml::listData. The problem is that when I’m editing root category I’m having this category itself available as option in drop-down list. How do I get rid of it?
in CGridView, if you want to use dropdown list as filter, you can do like this:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'columns'=>array(
//'reference_number',
array(
'name'=>'reference_number',
'value'=>'$data->reference_number',
'filter'=>CHtml::listData($model->findAllBySql('SELECT reference_number
FROM insurance_form
GROUP BY reference_number ORDER BY reference_number'), 'reference_number', 'reference_number'),
),
...
It will create a drop down list filter in the first quick search row. All values is from your current table, and options ordered by reference number.
if you want to see more examples about related fields, see:
//in model
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'carservicetypedetail' => array(self::BELONGS_TO, 'Carservicetypedetail', 'carservicetypedetail_id'),
'user' => array(self::BELONGS_TO, 'User', 'user_id'),
);
}