Sunday, March 6, 2022

[FIXED] Yii2, gridview can not show some html tags inside cells

Issue

I'm using GridView widget for displaying data in my Yii2 application. The gridview can not render some of html tags, such as <input> or <button>!.

here is part of my code:

[
     "label" => "Action",
     "format" => 'html',
     "value" => function($data){
           return '<input type="button" value="Action" />';
      }
]

This renders nothing inside <td>, just empty <td></td> !!

What's the problem?


Solution

The "html" formatter is piped through HtmlPurifier to clean it up.

If you want it to pass through without any filtering then use the format "raw" instead of "html"



Answered By - Ed209

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.