Answer the question
In order to leave comments, you need to log in
Why menu is not displayed in Yii2?
Created widget file:
use yii\bootstrap\Nav;
echo Nav::widget(
[
'items' => [
[
'label' => 'Ссылка 1',
'url' => [
'#'
]
],
[
'label' => 'Ссылка 2',
'url' => [
'#'
]
]
]/*,
[
'label' => 'Выпадающий список',
'items' => [
[
'label' => 'Ссылка 1',
'url' => [
'#'
]
],
'<li class="divider"></li>',
'<li class="dropdown-header">Описание</li>',
[
'label' => 'Ссылка 2',
'url' => [
'#'
]
]
]
]*/
]
);
Answer the question
In order to leave comments, you need to log in
Parentheses need to be placed correctly:
echo Nav::widget([
'items' => [
[
'label' => 'Ссылка 1',
'url' => '#'
],
[
'label' => 'Ссылка 2',
'url' => '#'
],
[
'label' => 'Выпадающий список',
'items' => [
[
'label' => 'Ссылка 1',
'url' => '#'
],
'<li class="divider"></li>',
'<li class="dropdown-header">Описание</li>',
[
'label' => 'Ссылка 2',
'url' => '#'
],
],
],
]
]);
This is definitely an extra nesting, you have commented out part of the code by clearly cutting off the extra ]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question