Hello i am new with the FrameWork and my problem concern my nav
1: when my user is logged i dont want to see this tab : [‘label’ => ‘Créer un compte’, ‘url’ => [‘/site/signup’]] and the login
so i made this for my probleme and it work well :
Yii::$app->user->isGuest
? [
['label' => 'ouverture de session', 'url' => ['/site/login']],
['label' => 'Créer un compte', 'url' => ['/site/signup']]
]
2:
when i am logged is work fine but now when is time to loggout is receive a error message : The ‘label’ option is required. [‘/site/logout’] not working…
see my full code : header nav
<header id="header">
<?php
NavBar::begin([
'brandLabel' => Html::img('@web/img/logo.png', ['alt' => 'Charte De Crypto', 'style' => 'height: 48px;margin-right: 10px;']) . "<h3 class='h3mobile;' style='font-weight: bold;color: white;'>" . Yii::$app->name . "</h3>",
'brandUrl' => Yii::$app->homeUrl,
'options' => ['class' => 'mynav fixed-top']
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav '],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'À Propos', 'url' => ['/site/about']],
['label' => 'Nous Contacter', 'url' => ['/site/contact']],
//['label' => 'Créer un compte', 'url' => ['/site/signup']],
// ['label' => 'Dire', 'url' => ['/site/dire']],
Yii::$app->user->isGuest
? [
['label' => 'ouverture de session', 'url' => ['/site/login']],
['label' => 'Créer un compte', 'url' => ['/site/signup']],
]
: '<li class="nav-item">'
. Html::beginForm(['/site/logout'])
. Html::submitButton(
'Se déconnecter (' . Yii::$app->user->identity->username . ')',
['class' => 'nav-link btn btn-link logout']
)
. Html::endForm()
. '</li>'
]
]);
NavBar::end();
?>
</header>
so what i need to do for fixing this problem
sincerely I find this very complicated for a logic that is simple
if example the code returns to the basic one everything works fine but just the fact that I added an additional condition inside the ? everything starts not to work
error here : localhost — Postimages