0

How to insert a line feed code into a character in textarea?

I'm using laravel5.4, with Formfacade.

this is my code.

Model:

User.php

public function getTagAttribute()
{
  $tags = $this->tags->pluck('tag_name')->toArray();
  return implode('\r\n', $tags);
 }

public function tags()
{
  $this->belongsToMany('App\Tag');
}

Blade:

{!!Form::textarea('tag', null, [
      'class' => 'form-control keyword',
      ])!!}

Output

"\r\n" characters are displayed in the textarea.  

I tried changing '\r\n' to '\n', '< br/>', but not worked.

anyone help me??

yn1043
  • 528
  • 2
  • 11
  • 24

1 Answers1

2

You need to change following line:

  return implode('\r\n', $tags);

to

  return implode("\r\n", $tags);

There is a big difference between single quote and double quote. Single quote will only except string and won't parse anything.

mukund
  • 2,253
  • 1
  • 18
  • 31