Reputation: 407
How can I create link template in Yii2 bootstrap Nav widget?
echo \yii\bootstrap\Nav::widget([
'options' => ['class'=>'top_choice'],
'items' => [
['label' => 'Finish', 'options' => ['class' => 'tab'], 'url' => ['/finish'], 'template' => '<a href="{url}"><span>{label}</span></a>']
]
]);
I need to receive:
<li class="tab"><a href="/v2/finish-by-code"><span>Finish</span></a></li>
But receive:
<li class="tab"><a href="/v2/finish-by-code">Finish</a></li>
Without span
Upvotes: 1
Views: 1465
Reputation: 133380
If you need html inside label you could use label and encode => false
echo \yii\bootstrap\Nav::widget([
'options' => ['class'=>'top_choice'],
'items' => [
['label' => '<span>Finish</span>', 'options' => ['class' => 'tab'],
'url' => ['/finish'],]
],
'encodeLabels' => false,
]);
Upvotes: 2
Reputation: 390
echo \yii\bootstrap\Nav::widget([
'encodeLabels' => false,
'options' => ['class'=>'top_choice'],
'items' => [
['label' => '<span>Finish</span>', 'options' => ['class' => 'tab'], 'url' => ['/finish']]
]
]);
Upvotes: 1