My database has fields containing index numbers (eg 0=‘Yes’, 1=‘No’, 2=‘Maybe’ etc). I want to display the text meaning of these index numbers in a CGridView column.
The following code is what I’ve tried, but doesn’t work. The refTypeID column is blank. The filter is working correctly.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'wallet1000-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array('name'=>'refTypeID','value'=>'$ReferenceName[$data->refTypeID]',
'filter'=>$ReferenceName),
array('value'=>'number_format($data->amount,2)','name'=>'amount'),
array('value'=>'number_format($data->balance,2)','name'=>'balance'),
),
)); ?>
refTypeID is the integer code, $ReferenceName is an array of text strings which are the values for each code (where key = refTypeID)
How can I display a human readable text value for an integer code ?