Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Blade ( Displaying data as new line)

So i have a <textarea> in my form. User can either enter a new line or single line. So when the user views the text it will be showed like how he/she inputs it.

Form

<textarea name="jo_unit" class = 'form-control' required="required" cols = '4'></textarea>

Expected Output

TESTING 1
TESTING 2
TESTING 3

What i get

What i get

My code on displaying it

{{ nl2br(@$get['result'][0]->jo_unit_2) }}
like image 272
jerome Avatar asked Oct 22 '25 12:10

jerome


1 Answers

Security: This code allows XSS attacks and is not production ready.

use {!! !!}:

{!! nl2br(@$get['result'][0]->jo_unit_2) !!}
like image 65
Sohel0415 Avatar answered Oct 25 '25 02:10

Sohel0415