vishalsuri
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 me3 replies
Redirect Unverified Users to Email Verification Page in Filament
I’ve started using Filament, and I’ve encountered an issue where users can access the dashboard immediately after signing up, even if their email is unverified. I want to enforce email verification by redirecting unverified users to the login page with a message prompting them to verify their email. Once their email is verified, they should be able to access the dashboard.
What is the best approach to implement this in Filament?
4 replies