nl2br not working?

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



    '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:


I used your code


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


Or even easier:

'type' => 'ntext'

and it does nl2br automagically.

Here is a list of all formatters: