Reputation: 3745
I'm using Yii2's Bootsrap Tabs widget (yii\bootstrap\Tabs -- http://www.yiiframework.com/doc-2.0/yii-bootstrap-tabs.html)
I want to insert HTML tags as the value of the label
key in the array that builds this widget.
I tried including the key => value pair of 'encode' => true
as one of the optional array elements but that did nothing.
Here's my code:
<?=
Tabs::widget([
'navType' => 'nav-pills',
'options' => ['class' => 'course-manager'],
'items' => [
[
'label' => '<i class="fa fa-book"></i> Show Books',
'encode' => true,
'content' => '<h2>Anim pariatur cliche...</h2>',
'active' => true
],
[
'label' => '<i class="fa fa-graduation-cap"></i><span> Show Students</span>',
'encode' => true,
'content' => 'Anim cliche...',
],
[
'label' => '<i class="fa fa-tags"></i><span> Show Licenses</span>',
'encode' => true,
'url' => 'http://www.example.com',
],
],
]);
?>
Those labels are being displayed as text instead of HTML.
Upvotes: 3
Views: 2037
Reputation: 133360
If you want that the html code is rendered you should use 'encodeLabels' => false,
Tabs::widget([
'navType' => 'nav-pills',
'options' => ['class' => 'course-manager'],
'encodeLabels' => false,
'items' => [
[
'label' => '<i class="fa fa-book"></i> Show Books',
'content' => '<h2>Anim pariatur cliche...</h2>',
'active' => true
],
Upvotes: 5