F
Filamentβ€’6mo ago
SJ

Dynamic Navigation with SubMenus not displaying

I build a dynamic Navigation from an Array with this function:
public function createNavigation(): Array
{
$navigation = [];
foreach (config('b65.navigation') as $menu => $submenus) {

foreach ($submenus as $submenu => $items) {

$navigation[] = NavigationItem::make($submenu)
->icon('heroicon-o-home')
->group($menu);

foreach ($items as $title => $link) {

$navigation[] = NavigationItem::make($title)
->url($link, shouldOpenInNewTab: true)
->parentItem($submenu)
->group($menu);

}

}

}

return $navigation;

}
public function createNavigation(): Array
{
$navigation = [];
foreach (config('b65.navigation') as $menu => $submenus) {

foreach ($submenus as $submenu => $items) {

$navigation[] = NavigationItem::make($submenu)
->icon('heroicon-o-home')
->group($menu);

foreach ($items as $title => $link) {

$navigation[] = NavigationItem::make($title)
->url($link, shouldOpenInNewTab: true)
->parentItem($submenu)
->group($menu);

}

}

}

return $navigation;

}
` But the Navigation does not show the Items in the SubMenus. What am I missing? The Documentation states, that the Navigation Item in the Submenu must contain the same Group from its parent.
No description
6 Replies
SJ
SJβ€’5mo ago
This drives me nuts, please any help will be appreciated Still nothing? Will I have to open an official Bug Report?
Lara Zeus
Lara Zeusβ€’5mo ago
I think you should use NavigationGroup::make() for the parent items then create all items without nesting, set the group and it should work
SJ
SJβ€’5mo ago
I did that. Unforunately I do get the same result. You cannot return any NavigationGroup Object within the navigationItems() Array and separating the creation of the groups to the navigationGroups Array results in an Error "Call to a member function keyBy() on null" because filament()->getNavigation(); seens not to see the group .. as i stated i wasted hours on this with any possible combinations 😦
Lara Zeus
Lara Zeusβ€’5mo ago
create the NavigationGroup separately from NavigationItem
->navigationGroups(getGroupsOnlyAsArray())
->navigationItems(createNavigation())
->navigationGroups(getGroupsOnlyAsArray())
->navigationItems(createNavigation())
SJ
SJβ€’5mo ago
.. separating the creation of the groups to the navigationGroups Array results in an Error "Call to a member function keyBy() on null" because filament()->getNavigation(); seems not to see the group .. tried it 😦 Sorry but i think this seems to be a bug. I will try a bug report on github Thanks for the replies!
Want results from more Discord servers?
Add your server
More Posts
Any tips on how I could approach a single sign-in form for two panels?I'd like to have a single sign-in form that dynamically redirects the user to the appropriate panel history.replaceState error in safari when having many components with actionsSo, when I have a lot of components that use actions, I get history.replaceState in safari (or its eEdit Page not showing Hidden FieldI am encountering this problem with a Conditional Select Field where if the role of the user is VendRefresh Form With Dynamic Element NamesI have a form that I call from a relation manager. The form has two pieces - the first piece shows tany idea for improving file pond loading?Hi guys, I have a lot of file inputs in my filament project, and when the page loads the file input Possible to use infolists with Relation Manager?Is it possible to have a Relation Manager that displays results as an infolist rather than a table? Set default value to a select, listening the change from another input```php Forms\Components\DatePicker::make('extinguisher_expiration')->live(debounce: 500), Forms\Compfilament Table main content goes under the footer.Hello, I am working on an Livewire component with an filament table (made via: `php artisan make:livNotifications transition glitches in FirefoxHas anyone else experienced the Notifications panel slide out and "overshooting" then abruptly snapphow to show the mobile number with country codeI want to combine values of two table columns and show them in the one column. how do i acheive tha