Custom `EditProfile` page in multi-tenancy causes `Missing required parameter`
Package
filament/filament
Package Version
v3.0.91
Laravel Version
v10.30.1
Livewire Version
v3.1.0
PHP Version
PHP 8.2.13
Problem description
When adding a custom EditProfile screen to a panel with multi-tenancy, a missing required tenant parameter causes the tenant registration page to trigger an exception.
Expected behavior
When you visit a panel route without a tenant it should gracefully fail somehow. You can't create a team without a team if you have a custom EditProfile page created within the panel.
Steps to reproduce
- Seed the database in the demo repo
- Visit http://localhost/app
- See the
Missing required parameter for [Route: filament.app.pages.edit-profile] [URI: app/{tenant}/edit-profile] [Missing parameter: tenant].
Reproduction repository
https://github.com/johncarter-/filament-demo/tree/issue/tenant-create-edit-profile
Relevant log output
No response
I understand that this is could be considered not necessarily a bug and understand you way want to close it. But i believe it to be important for others to find should they run into the same issue.
The problem lies in having the EditProfile class extend a Filament\Pages\Page when I think it has to extend a Filament\Pages\SimplePage.
You are not extending Filament's EditProfile page, you're extending the base class?
Well I wanted the profile page to use the same layout (nav, etc) and styling as one of my panels, so this seemed the logical choice.
It seems that panel layouts with a null tenant seem to be a no-no - right?
The reason why it's outside of the "tenant" area is because otherwise, a user without tenants wouldnt be able to access their profile, as the sidebar is required to render that layout
There isn't stopping you from using make:filament-page and creating the profile page like a normal custom page, but you won't use $panel->profile() and instead add the link to the user menu manually
Thanks Dan, I'll give that a go. If I have success I'll update this issue. Feel free to close.
Gonna close this as I think that solved the problem for you.
What solved my problem form in filament multi-tenacy was instead of extending Filament\Pages\Auth\EditProfile instead use Filament\Pages\Tenancy\EditTenantProfile it works
For anyone else looking I figured this out and it might help... It looks like the intended method is to set your profile page as simple page by passing the argument to the ->profile method like so:
->profile(EditProfile::class, true)
This will make the profile page come in a simplePage view getting rid of any of the Tenant parameter requirements. You only need to account for any menu items you might have configured in your panel.
'MyItem' => MenuItem::make()
->label('MyItem')
->hidden(fn(): bool => Filament::getTenant() === null) // <--- this will keep the menu item from rendering when a tenant is not identifiable
->url(fn(): string => route('filament.pages.myitem', Filament::getTenant()))