時,我要表現出的DetailView用戶的詳細信息比它拋出:機能的研究()中的DetailView不工作yii2
用htmlspecialchars()預計參數1是字符串,對象給出
以下是我的DetailView代碼:
view.php
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'userID',
'userEmail:email',
'userName',
'userMobile',
'userBirthDate',
'userGender',
[
'attribute' => 'interestName',
'format' => 'raw',
'label' => 'Interest',
'value' => $model->getUserinterest(),
],
'userStatus',
'userType',
],
]);
?>
function getUserinterest() {
foreach ($model->userinterest as $userinterest) {
$interestNames[] = $userinterest->interestName;
}
return implode("\n", $interestNames);
}
什麼是你Yii2版本? – Yupik
Yii2版本是:2.0.10 – Akkie