I have a Form with Symfony 2 with a textarea.
If the user writes something like this in the textarea
word1
word2 word3 word4
word5
rest of message
i'm getting the data exactly like this from the form, but without any HTML linebreaks. So if i want to use this text further for sending a email it'll be shown as this
word1 word3 word4 word5 rest of message
How can i save the formatting of the Text? Any suggestions?
If you are wanting to use this in a Twig template then you should use the nl2br
filter like..
{{ text|nl2br }} // NOT "bl2br" as I had originally written.
You can use nl2br function:
$text = nl2br($text);
echo $text;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With