I tried searching this in google and here in Yii Community (I tried searching after going through reading the docs/class reference regarding CGridView and it’s related classes), but I couldn’t find any topics related to my problem. Is it just me that I’m too dumb to miss out a simple problem?
Anyways, I have a database with text in it. It got lots of newlines, and the most basic way to preserve those newlines is to use nl2br. But when I tried to use it in CGridView, it didn’t work well as expected. Here’s an example of what I’m trying to say:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'kerror-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'error',
'err_msg',
array(
'name'=>'ok',
'value'=>'nl2br($data->ok)',
),
array(
'name'=>'rc',
'value'=>'nl2br($data->rc)',
),
array(
'name'=>'ng',
'value'=>'nl2br($data->ng)',
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
This problem also exists in CDetailView.
The output is usually this:
Wherein it should’ve have been:
Am I the only one who ran into this problem or is there anyone else out there who ran into this problem but isn’t as dumb as me that he/she got it to work well?