Sam*_*yek 3 twitter-bootstrap yii2 yii-widgets
我正在使用 Yii2 的 Bootsrap Tabs 小部件(yii\bootstrap\Tabs -- http://www.yiiframework.com/doc-2.0/yii-bootstrap-tabs.html)
我想label在构建此小部件的数组中插入 HTML 标签作为键的值。
我尝试将 key => value 对'encode' => true作为可选数组元素之一包含在内,但没有做任何事情。
这是我的代码:
<?=
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',
],
],
]);
?>
Run Code Online (Sandbox Code Playgroud)
这些标签显示为文本而不是 HTML。
如果您希望呈现 html 代码,您应该使用 '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
],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1622 次 |
| 最近记录: |