【发布时间】:2016-11-29 07:17:54
【问题描述】:
我在 Yii 2 的 DetailView 中使用下面的代码时遇到了这个错误。
闭包类的对象无法转换为字符串
代码是:
[
'format' => 'raw',
'attribute' => 'title',
'value' => function($model1, $key) {
if ($model1->book->language == 1) {
$m = "<p class='n'>" . $model1->book->title . "</p>";
} else {
$m = $model1->book->title;
}
return $m;
},
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center']
],
你们能帮帮我吗?
【问题讨论】:
标签: yii2