我只想在导航栏中为登录用户添加配置文件。我在 dektrium yii2-user 文档中找到了 /user/profile/show 。
但它说:
显示用户的个人资料(需要 id 查询参数)
如何在需要id查询参数的标签中实现/user/profile/show?
提前致谢
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/user/registration/register']];
$menuItems[] = ['label' => 'Login', 'url' => ['/user/security/login']];
} else {
$menuItems[] = ['label' => 'Profile', 'url' => ['/user/profile/show']];
$menuItems[] = '<li>'
. Html::beginForm(['/user/security/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link']
)
. Html::endForm()
. '</li>';
}
当我使用上面的代码并单击配置文件导航栏时,它显示错误请求(#400),缺少所需参数:id。是的,我知道因为没有定义 id 查询参数。