How do I not encode html in CGridView columns

I’ve seen the answer to this somewhere in the api doc but can’t for the life of me find it. I want to render an <img> tag in a column. I think you specify it in the htmlOptions attribute but I’ve tried this with;




htmlOptions=>('encode'=>false')



…but that don’t work…

i´m not sure, but try this:




...

'columns' => array(

...

array(

...

'type'=>'raw'

),

...

),



There wasn’t any reply to the suggestion, so I thought I would (even though it’s been a while). Setting the type to raw did, in fact, do the trick. I had the same issue, and I came across this post, so I wanted to confirm the solution and say “thanks” to Flavio. :)

try this out htmlOptions=>(‘encode’=>0)

:)

array( ‘encode’=>0, ‘class’=>‘icon liked tips’, ‘aria-hidden’=>‘true’,

‘data-icon’=>’&#x2d;’,

)

This seems to work:


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'alarm-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'property1',  // property1 will be HTML-encoded

                 array(

                    'name'=>'property2',

                    'type'=>'raw',

                    ),                // property2 will not be HTML-encoded

		'property3',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>