Answer the question
In order to leave comments, you need to log in
How to insert icon and value into label in gridview?
How to insert an icon and value something like this
in the gridview in the label , but it does not work
[
'attribute' => 'user_id',
'label' => function ($data) {
return '<i class="fa fa-user-circle" aria-hidden="true"></i>' . $data->user_id;
},
Answer the question
In order to leave comments, you need to log in
first, if you use the standard \yii\grid\DataColumn then the label property cannot accept an anonymous function. Secondly, in order to display the html content correctly, you need to set the encodeLabel parameter to false
. For example, like this:
[
'attribute' => 'user_id',
'label' => '<i class="fa fa-user-circle" aria-hidden="true"></i>',
'encodeLabel' => false
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question