我有现场"状态"在我的表中,字段值为1或2。 我希望显示GridView yii2,如果1然后激活,如果2则不激活
答案 0 :(得分:1)
[
'format' => 'html',
'attribute' => 'field_name',
'value' => function($data) {
return ($data->field_name == 1 ? 'active' : 'not active');
},
],
您可以尝试使用此代码