Laravel-datatables: editColumn escaping HTML

Created on 29 May 2017  路  2Comments  路  Source: yajra/laravel-datatables

Summary of problem or feature request

I'm looking to edit a column to include a link. It's working, except the HTML is being escaped therefore rendered as text instead of HTML.

Not sure what I am missing to have the HTML not be escaped. I have passing a template as the second argument and placing the HTML::linkRoute call in the template file, but same result.

Code snippet of problem

return Datatables::of($people)
    ->editColumn('firstname', '{!! HTML::linkRoute("person.show", $firstname, $userid) !!}')
    ->make(true);

And it returns:

firstname: "<a href="http://myurl.localhost/person/516073">SomeFirstName</a>"

System details

  • Debian 8
  • 7+
  • 5.4
  • 7.2

Most helpful comment

Answering my own question. Solution was using the well documented raw columns.

return Datatables::of($people)
    ->editColumn('firstname', '{!! HTML::linkRoute("person.show", $firstname, $userid) !!}')
    ->rawColumns(['firstname'])
    ->make(true);

All 2 comments

Answering my own question. Solution was using the well documented raw columns.

return Datatables::of($people)
    ->editColumn('firstname', '{!! HTML::linkRoute("person.show", $firstname, $userid) !!}')
    ->rawColumns(['firstname'])
    ->make(true);

for versions above 8, u have to go to config/datatables.php file....and add your column name in ....raw => ['name_of your_column']

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fanjavaid picture fanjavaid  路  32Comments

faisalhilmi picture faisalhilmi  路  18Comments

FaZeRs picture FaZeRs  路  18Comments

jay-shah-rushiinfotech picture jay-shah-rushiinfotech  路  19Comments

AbuHamdah picture AbuHamdah  路  33Comments