0
我使用的DetailView小部件,我想寫自定義函數值,但我不斷收到此錯誤:Yii2用htmlspecialchars()預計參數1是字符串,對象給出
htmlspecialchars() expects parameter 1 to be string, object given
這是代碼:
[
'label' => 'Keys',
'value' => function($model, $key, $inde){
if(!empty($model->keys))
return '<strong>User don\'t have any key at the moment.</strong>';
$keys = '';
foreach($model->keys as $key):
$keys .= '<strong>' . $key->key . '</strong>';
endforeach;
return $keys;
}
],
我在做什麼錯了?
如果您將''format'=>'raw''添加到您的數組中,會發生什麼? –