I have added a dropdown list for a couple of the columns in my CGridView on the admin page…
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'plan-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'name',
'filter' => CHtml::listData(Plan::model()->findAll($criteria), 'name', 'name'),
'value'=>'$data->name',
),
array(
'name'=>'style',
'type'=>'raw',
'filter' => CHtml::listData(PlanStyle::model()->findAll(), 'description', 'description'),
'value'=>'$data->style->description',
),
'beds',
'baths',
array(
'name'=>'squareFootage',
'value'=>'Yii::app()->NumberFormatter->format("#,##0 sq. ft.", $data->squareFootage)',
),
array(
'name'=>'deleted',
'value'=>'$data->getStatus($data->deleted)',
'cssClassExpression' => "active",
),
array(
'class'=>'CButtonColumn',
'header'=>'Operations',
'buttons'=>
array('delete'=>
array('label'=>'Activate/Deactivate',
),
),
'deleteConfirmation'=>false,
),
),
This works fine except that several of the items in the ‘style’ column are stored in the database with the ½ HTML character entity and when displayed in the dropdown menu, the & of ½ is encoded.
This means the HTML that is generated is
<option value="1&frac12; Story">1&frac12; Story</option>
instead of
<option value="1½ Story">1½ Story</option>
The values of that grid column display correctly because I use ‘type’=>‘raw’ to prevent encoding
array(
'name'=>'style',
'type'=>'raw',
'filter' => CHtml::listData(PlanStyle::model()->findAll(), 'description', 'description'),
'value'=>'$data->style->description',
),
Is there something similar I can do with CHtml::listData()?
Thanks