There's this <abbr></abbr>
tag in bootstrap that will automatically shows popup of the abbreviated word. I want to insert this tag to a certain header in the gridview with attribute name act
. Here is my code so far.
[
'attribute'=>'act',
'format'=>'raw',
'label'=>'<abbr title="Area Coordinating Team">ACT</abbr>',
'value'=>function($model){
return '<span class="fa fa-thumbs-up text-green"></span>';
}
],
but the output literally shows the whole <abbr title="Area Coordinating Team">ACT</abbr>
Yii Framework 2 : Gridview. In yiiframework 2.0, The gridview widget is used to display the data like image, text, etc in a grid. It is having a lot features like sorting, pagination, filtering, styling etc. This widgets is mostly used by developers.
Let's review basic steps of creating a custom Yii2 widget firstly. Override init and run method of yii\base\Widget. init is used to do some initializing work, run is responsible for rendering the view of a widget. In earlier basic tutorial, we do lots of HTML echoing work in run method.
Configure the gridview button or template, header lable value and button options like class, style etc. Add the new button in gridview action template and configure the url, text, title etc. If we would like to set the HTML attributes for 'Gridview' table cells in yii2.0, Just use the 'contentOptions' parameter for that cell.
Show/Hide the summary text, footer and header of gridview table yii2.0. Hide the gridview using 'showOnEmpty' properties If the data is not available to show in gridview table. Every developer would like to play with gridview action. I added the code for that from my experience.
I already answered that here.
To achieve that, use header
property instead of label
:
[
'attribute' => 'act',
'format' => 'raw',
'header' => '<abbr title="Area Coordinating Team">ACT</abbr>',
'value' => function ($model) {
return '<span class="fa fa-thumbs-up text-green"></span>';
},
],
That way HTML content won't be encoded.
Official docs:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With