I want my menu to have more than 2 levels. Looks like Yii 2 only renders up to 2 levels. For example this:
NavBar::begin();
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
[
'label' => 'Level 1',
'items' => [
['label' => 'Level 2 - 1', 'url' => '#'],
['label' => 'Level 2 - 2', 'url' => '#'],
[
'label' => 'Level 2 - 3',
'items' => [
['label' => 'Level 3 - 1', 'url' => '#'],
['label' => 'Level 3 - 2', 'url' => '#'],
],
],
]
],
],
]);
NavBar::end();
will not display the Level 3 - x menu items. How do I add more levels to the menu?
1) Add Css in /web/css/site.css
2) Add submenu and attributes 'itemsOptions' , 'submenuOptions', 'items':
3) ok !!
This is not Yii 2 limitation, it's Boostrap 3 limitation.
Here is quote from mdo (one of the main Boostrap 3 contributors):
It's taken from here.
However you can find some alternatives to use more levels. For example take a look this extension.
Also this question is discussed with more details and examples here.
Try to use this extension of
Nav
widget.