how to use drop down list of a cgrid view in yii?

Hi I know this should be really simple but am just too new to php and yii.SO please bear with me . I have a table named thefriends which has columns(id,thepals,address,phone numbers). Now the admin page uses a cgrid view to list all these friends in the usual format. I want the text boxes to be replaced by drop down menus. I know it can be done by using the following code in views/Thefriends/admin.php









But as you see I have to populate the values myself, instead I want all the values to be prepopulated from the particular column in the table… please help…

Maybe send them from your controller:

public function actionSomething(){

  $criteria = new CDbCriteria;



  $dp = new CActiveDataProvider('Model', array('criteria' => $criteria))


  $c = clone $criteria;

  $c->select = 'id, value';

  $f = Model::model()->findAll($c);

  $filter = array();

  foreach($f as $m){

    $filter[$m->id] = $m->value;



  $this->render('view', array(

    'dp'=> $dp,

    'filter' => $filter,



[size="1"]Note: totally untested and written in the forum editor[/size]