D
D
DragonChris2017-08-09 16:38:23
Yii
DragonChris, 2017-08-09 16:38:23

Yii2 How to display an icon in a label?

It is necessary that in breadcrumbs, the link to the main page be an icon, encodeLabels set to false, but just my tag is displayed. Tell me what I'm doing wrong. Thanks in advance.

$this->params['breadcrumbs'][] =  [
    'template' => "<li>{link}</li>\n",   
    'label' => 'Objects',
    'url' => ['/objects'],
    'encodeLabels' => false
];

I output:
<?= Breadcrumbs::widget(['homeLink' => ['label' => "<i class=\"fa fa-home\" aria-hidden=\"true\"></i>"],'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], ]); ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-08-09
@DragonChris

encodeLabels

<?= Breadcrumbs::widget([
'encodeLabels' => false,

M
Maxim Fedorov, 2017-08-09
@qonand

Breadcrumbs::widget([
    'homeLink' => [
        'label' => "<i class=\"fa fa-home\" aria-hidden=\"true\"></i>"
        'encode' => false,
        'url' => Yii::$app->homeUrl
    ]
   ....
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question