Yii2 detailView 根据条件突出显示值
Yii2 detailView highlight value on condition
如何根据条件在 yii2 detailView 中高亮显示值?
我试过这种方式(有和没有 'type' => 'raw'
、'html'
),但没有成功:
[
'attribute' => 'attribute',
'type' => 'raw',
'value' => $model->attribute > 1 ? '<b>' . $model->attribute . '</b>' : $model->attribute,
],
谢谢!
您需要使用 format
属性,而不是 type
:
'format' => 'html'
如何根据条件在 yii2 detailView 中高亮显示值?
我试过这种方式(有和没有 'type' => 'raw'
、'html'
),但没有成功:
[
'attribute' => 'attribute',
'type' => 'raw',
'value' => $model->attribute > 1 ? '<b>' . $model->attribute . '</b>' : $model->attribute,
],
谢谢!
您需要使用 format
属性,而不是 type
:
'format' => 'html'