beg*_*ner 6 html formatting gridview yii2 yii2-advanced-app
<abbr></abbr>bootstrap中有这个标签会自动显示缩写词的弹出窗口.我想将此标记插入到gridview中具有属性名称的某个标题中act.到目前为止,这是我的代码.
[
'attribute'=>'act',
'format'=>'raw',
'label'=>'<abbr title="Area Coordinating Team">ACT</abbr>',
'value'=>function($model){
return '<span class="fa fa-thumbs-up text-green"></span>';
}
],
Run Code Online (Sandbox Code Playgroud)
但输出字面上显示了整体 <abbr title="Area Coordinating Team">ACT</abbr>

小智 9
使用:'encodeLabel'=> false,
[
'attribute'=>'act',
'format'=>'raw',
'label'=>'<abbr title="Area Coordinating Team">ACT</abbr>',
'encodeLabel' => false,
'value'=>function($model){
return '<span class="fa fa-thumbs-up text-green"></span>';
}
],
Run Code Online (Sandbox Code Playgroud)
我已经回答了这里.
要实现这一点,请使用headerproperty而不是label:
[
'attribute' => 'act',
'format' => 'raw',
'header' => '<abbr title="Area Coordinating Team">ACT</abbr>',
'value' => function ($model) {
return '<span class="fa fa-thumbs-up text-green"></span>';
},
],
Run Code Online (Sandbox Code Playgroud)
这样就不会对HTML内容进行编码.
官方文档: