I am new in Laravel.I have a laravelcollective textarea in my blade that I store its value in a database:
{!! Form::textarea('TaskDsc',null,['style'=>'height: 113px;width:150%;','class'=>'p-2']) !!}
When I write the text in several lines and save it in the database, the <p>
tag is stored with them inside the table.
<p> line 1 </p><p> line 1 </p>
When I write the text in several lines and save it in the table, the <p>
tag is added inside the table.
The problem is that when I read the data from the table and display it in the textarea in edit blade , it is displayed with the <p>
tag and as it is stored in the database. While I want the <p>
tag
Delete and display each paragraph separately and below
line1
line2
2
Answers
You can replace all
<p>
byn
before input in textarea and replace alln
by<p>
before save to database.You can use PHP
strip_tags()
(w3schools)The
isset()
function is used to prevent errors in strip_tags when no value is passed.