Create more than 2-th level
opened this issue · comments
Deleted user commented
Can I create more than 2-th level of menu (for example admin->settings->users)? Thanks for answer.
Marco A. commented
Did you try this:
$menu = $app['knp_menu.factory']->createItem('root');
$menu->addChild('admin', array('uri' => '/admin'));
$menu['admin']->addChild('settings', array('uri' => '/admin/settings'));
$menu['admin']['settings']->addChild('users',array('uri'=>'/admin/settings/users'));
return $menu;
Christophe Coevoet commented
what @Kwbmm said is working. Note that ->addChild()
also returns the Item object for the new child (the one you would also access with $menu['admin']
)