我有一个名为Play的表,我在Yii2详细视图小部件中显示每条记录的详细信息.我在该表中有一个属性recurring为tinyint 的属性,它可以是0或1.但我不想将其视为数字,而是我想显示yes或no基于值(0或1).
我正在尝试使用detailview小部件中的函数更改它,但我收到一个错误: Object of class Closure could not be converted to string
我的详细视图代码:
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'name',
'max_people_count',
'type',
[
'attribute' => 'recurring',
'format'=>'raw',
'value'=> function ($model) {
if($model->recurring == 1)
{
return 'yes';
}
else {
return 'no';
}
},
],
'day',
'time',
...
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激 !