Search code examples
yiicgridview

yii cgridview dropdownlist value


I am unable to set the value of the column day in the cgrid view : I am able to see the dropdownlist but all have the same day Monday set irrespective of the value of the day as represented by $data->day

$this->widget('zii.widgets.grid.CGridView', array(
        'dataProvider'=>$dataProvider,
        'columns'=>array(
        array(
            'type'=>'raw',
            'name'=>'day',
        'value'=> ' CHtml::dropDownList(\'someName\'.$row,\'$data->day\',array(
                    \'Mo\'=>\'Monday\',
                    \'Tu\'=>\'Tuesday\',
                    \'We\'=>\'Wednesday\',
                    \'Th\'=>\'Thursday\',
                   \'Fr\'=>\'Friday\',
                   \'Sa\'=>\'Saturday\',
                   \'Su\'=>\'Sunday\',))',  

                ),
            'ts_id'
        )
    )); 

Solution

  • Just a minor issue resolved the whole episode. I had put quotes around $data->day in the original post. which was not needed.

       array(  'type'=>'raw',
                'name'=>'day',
                'value'=> ' CHtml::dropDownList(\'someName\'.$row,$data->day,
                 array(\'Mo\'=>\'Monday\',
                            \'Tu\'=>\'Tuesday\',
                            \'We\'=>\'Wednesday\',
                            \'Th\'=>\'Thursday\',
                           \'Fr\'=>\'Friday\',
                           \'Sa\'=>\'Saturday\',
                           \'Su\'=>\'Sunday\',)
                  )',  
         ),