Error Accessing Custom Page in Filament User Menu: generateRouteName Null Issue

I created a custom page in Filament without using a resource and added it to the user-side menu. When trying to access the page URL with CompleteOrganization::getUrl() in the menu configuration, I'm encountering two different errors depending on the implementation: Error 1: sql Copy code Call to a member function generateRouteName() on null This occurs with the following menu item code: php Copy code ->userMenuItems([ 'profile' => MenuItem::make()->label('Edit profile'), 'complete-organization' => MenuItem::make()->label('Organization') ->url(CompleteOrganization::getUrl()), 'logout' => MenuItem::make()->label('Log out'), ]) Error 2: No default Filament panel is set. You may do this with the default() method inside a Filament provider's panel() configuration. This error occurs when using the code: php ->userMenuItems([ 'profile' => MenuItem::make()->label('Edit profile'), 'complete-organization' => MenuItem::make()->label('Organization') ->url(CompleteOrganization::getUrl([], true, 'complianceHub')), 'logout' => MenuItem::make()->label('Log out'), ]) My Findings: After investigating, the issue seems to stem from the getRouteName method in the Filament Page class: public static function getRouteName(?string $panel = null): string { $panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel(); $routeName = 'pages.' . static::getRelativeRouteName(); $routeName = static::prependClusterRouteBaseName($routeName); return $panel->generateRouteName($routeName); } Here, $panel is null in the first case, leading to the generateRouteName null error. In the second case, Filament can't determine the default panel when explicitly passing Please suggest or guide me
Solution:
Its resolved issue was ->url(fn (): string => CompleteOrganization::getUrl()), instead of passing directly we need to pass via function method so resolved, thanks
Jump to solution
1 Reply
Solution
vishalsuri
vishalsuri2w ago
Its resolved issue was ->url(fn (): string => CompleteOrganization::getUrl()), instead of passing directly we need to pass via function method so resolved, thanks
Want results from more Discord servers?
Add your server