G
G
Ghost26922018-05-11 20:50:38
Yii
Ghost2692, 2018-05-11 20:50:38

How to add yii2 HTML tags to GridView header?

I want to add tags to the heading 'label' => tex . 'tags',

[
                    'label' => $data->subject . '<i class="material-icons">swap_vert</i>',
                    'attribute' => 'subject',
                    'format' => 'raw',
                    'value' => function ($data) {
                        return Html::a($data->subject, Url::to(['report/view', 'id' => $data->id]));
                    },
                    'filterInputOptions' => ['class' => 'form-control form-control-sm'],
],

How can you do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-05-12
@Ghost2692

Good afternoon.
Use encodeLabel so you can add the tag.

[
     'label' => $data->subject . '<i class="material-icons">swap_vert</i>',
     'encodeLabel' => false,
     'attribute' => 'subject',
     'format' => 'raw',
     'value' => function ($data) {
          return Html::a($data->subject, Url::to(['report/view', 'id' => $data->id]));
    },
    'filterInputOptions' => ['class' => 'form-control form-control-sm'],
],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question