Yii2 - Textarea does not show linebreaks

2.7k Views Asked by At

I'm wondering about that the default textarea of Yii2 does not show newlines per default. And the Yii2 model does not save the newlines into the DB.

I didn't found anything in the Yii2 documentation, so hopefully you guys can help me - this is more than weird for me :-(

2

There are 2 best solutions below

1
On

You could use the ntext format in widgets such as ListView, GridView:

'format' => 'ntext',

ntext: the value is formatted as an HTML-encoded plain text with newlines converted into line breaks.

1
On

Introduce "word-wrap" as in any normal html. In your case.

<?= $form->field($studio, 'studioDescription')->textArea(array('rows'=>25, 'style' => 'resize:none; word-wrap:break-word;'))->label( PhobUtils::t('Description') ) ?>