nl2br not working?

Can any one help me why nl2br is not working this way

    array(


    'name'=>'abstract',


    'value'=>nl2br ('$data->abstract'),


    ),

but this why is working.

<?php echo nl2br(CHtml::encode($model->abstract)); ?>

What are you doing is that you send to nl2br the text "$data->abstract"… not the value of that attribute…

you need to include the complete expression in quotes like:


'value'=>'nl2br($data->abstract)',

I used your code

‘value’=>‘nl2br($data->abstract)’

but got this result

This is test<br /> This is test<br /> This is test

So nl2br is working :D

to solve that you need to add


'type'=>'raw'

Or even easier:


'type' => 'ntext'

and it does nl2br automagically.

Here is a list of all formatters: http://www.yiiframework.com/doc/api/1.1/CFormatter