I am trying to show a ticked image if my value if set to Y. I followed this post but I get the following as contents of my grid column instead of the image:
<img src="/webapp/images/tickedS.jpg" alt="" />
Following is my model code for the new method that I wrote:
public function getSurgeryFlaged(){
return $this->flag_for_dashboard=='Y' ? CHtml::image(Yii::app()->baseUrl .'/images/tickedS.jpg') : '';
}
Following is column option for CGridView :
'SurgeryFlag'=>array('name'=>'Flag','value'=>'$data->surgeryFlaged','htmlOptions'=>array('width'=>'50')),
Instead of Model property, if I create a Controller protected method, the result is the same. Kindly guide, what am I doing wrong…?
Thanks in advance.
Regards,
Faisal
You should use ‘raw’ as the type. see CFormatter
raw: the attribute value will not be changed at all.