php - Getting unknown property in Yii
one text
Solution:
Have to make 2 changes to your code.
- Change all
$model->isActive
to$model->active
. - Return "Yes" or "No" depending to
$model->active
value.
Update DetailView
:
[
'attribute' => 'active',
'value' => function ($model) {
return $model->active ? "Yes" : "No";
},
'contentOptions' => ['style' => $model->active ? 'color:green' :'color:red']
],
Update GridView
:
[
'attribute' => 'active',
'value' => function ($model) {
return $model->active ? "Yes" : "No";
},
'contentOptions' => function ($model, $key, $index, $column) {
return $model->active ? ['style' => 'color:green'] : ['style' => 'color:red'];
}
],
Source