skip to Main Content

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


  1. You can replace all <p> by n before input in textarea and replace all n by <p> before save to database.

    Login or Signup to reply.
  2. You can use PHP strip_tags() (w3schools)

    {!! Form::textarea('TaskDsc', isset($TaskDsc) ? strip_tags($TaskDsc) : null, ['style'=>'height: 113px;width:150%;','class'=>'p-2']) !!}
    

    The isset() function is used to prevent errors in strip_tags when no value is passed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search