i am newbee in yii and i am learning at this moment ...
I am using in model this query to get assosiative array for my listbox
public function getAllCategories()
{
$cats = $this->model()->findAll(array('select'=>'id,name'));
$mainarr = array();
foreach($cats as $obj)
$mainarr["$obj->id"]=$obj->name;
return $mainarr;
}
and on my form i am calling this function in my dropdownlist as this
<?php echo $form->dropDownList($model,'name',$model->getAllCategories()); ?>
I have so many drop down with many different queries and i dont find any faster way to do that and everytime i have to create above array to make it fulfill. Kindly advise me better and faster solution to populate if there is any using CActiveForm?