Petro Gromovo
Petro Gromovo

Reputation: 2183

Why multi-tenancy missing parameter error with xustom filament registration form?

Reading docs https://laraveldaily.com/post/filament-registration-form-extra-fields-choose-user-role

I want add fields for register form, but opening "/app/register" I got error :

Missing required parameter for [Route: filament.app.pages.register] [URI: app/{tenant}/register] [Missing parameter: tenant].

as I have 2 apps and file app/Providers/Filament/AppPanelProvider.php I have :

<?php

namespace App\Providers\Filament;

use App\Filament\App\Pages\Auth\Register;
use App\Filament\App\Pages\Tenancy\RegisterBranch;
...

class AppPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('app')
            ->path('app')
            ->login()
            ->profile()
            ->registration()
            ->registration(Register::class)
            ...

How that can be fixed ?

"laravel/framework": "^10.28.0",
"filament/filament": "^3.0-stable",

Thanks in advance!

MORE DETAILS :

It was very stuped on me to leave 2 registration methods, but removing 1st and leaving line with :

->registration(Register::class)

I got the same error (full error description):

[previous exception] [object] (Illuminate\\Routing\\Exceptions\\UrlGenerationException(code: 0): Missing required parameter for [Route: filament.app.pages.register] [URI: app/{tenant}/register] [Missing parameter: tenant]. at /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Exceptions/UrlGenerationException.php:35)
[stacktrace]
#0 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/RouteUrlGenerator.php(90): Illuminate\\Routing\\Exceptions\\UrlGenerationException::forMissingParameters()
#1 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php(502): Illuminate\\Routing\\RouteUrlGenerator->to()
#2 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php(471): Illuminate\\Routing\\UrlGenerator->toRoute()
#3 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(811): Illuminate\\Routing\\UrlGenerator->route()
#4 /ProjectPath/vendor/filament/filament/src/Pages/Page.php(41): route()
#5 /ProjectPath/vendor/filament/filament/src/Pages/Page.php(131): Filament\\Pages\\Page::getUrl()
#6 /ProjectPath/vendor/filament/filament/src/Pages/Page.php(67): Filament\\Pages\\Page::getNavigationUrl()
#7 /ProjectPath/vendor/filament/filament/src/Pages/Page.php(51): Filament\\Pages\\Page::getNavigationItems()
#8 /ProjectPath/vendor/filament/filament/src/Panel/Concerns/HasNavigation.php(48): Filament\\Pages\\Page::registerNavigationItems()
#9 /ProjectPath/vendor/filament/filament/src/Panel/Concerns/HasNavigation.php(99): Filament\\Panel->mountNavigation()
#10 /ProjectPath/vendor/filament/filament/src/FilamentManager.php(230): Filament\\Panel->getNavigation()
#11 /ProjectPath/storage/framework/views/e0b7f760cfa96da7f17519e93843f3d8.php(2): Filament\\FilamentManager->getNavigation()
#12 /ProjectPath/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(124): require('...')
#13 /ProjectPath/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(125): Illuminate\\Filesystem\\Filesystem::Illuminate\\Filesystem\\{closure}()
#14 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire()
#15 /ProjectPath/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(22): Illuminate\\View\\Engines\\PhpEngine->evaluatePath()
#16 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(72): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->evaluatePath()
#17 /ProjectPath/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(10): Illuminate\\View\\Engines\\CompilerEngine->get()
#18 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(207): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->get()
#19 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(190): Illuminate\\View\\View->getContents()
#20 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(159): Illuminate\\View\\View->renderContents()
#21 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Concerns/ManagesComponents.php(103): Illuminate\\View\\View->render()
#22 /ProjectPath/storage/framework/views/2bf9dfed71ca9e3c70e9b9870e86135c.php(17): Illuminate\\View\\Factory->renderComponent()
#23 /ProjectPath/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(124): require('...')
#24 /ProjectPath/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(125): Illuminate\\Filesystem\\Filesystem::Illuminate\\Filesystem\\{closure}()
#25 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire()
#26 /ProjectPath/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(22): Illuminate\\View\\Engines\\PhpEngine->evaluatePath()
#27 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(72): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->evaluatePath()
#28 /ProjectPath/vendor/livewire/livewire/src/Mechanisms/ExtendBlade/ExtendedCompilerEngine.php(10): Illuminate\\View\\Engines\\CompilerEngine->get()
#29 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(207): Livewire\\Mechanisms\\ExtendBlade\\ExtendedCompilerEngine->get()
#30 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(190): Illuminate\\View\\View->getContents()
#31 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/View.php(159): Illuminate\\View\\View->renderContents()
#32 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(333): Illuminate\\View\\View->render()
#33 /ProjectPath/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(353): Illuminate\\View\\Compilers\\BladeCompiler::render()
#34 /ProjectPath/vendor/livewire/livewire/src/Features/SupportPageComponents/SupportPageComponents.php(150): Illuminate\\Support\\Facades\\Facade::__callStatic()
#35 /ProjectPath/vendor/livewire/livewire/src/Features/SupportPageComponents/HandlesPageComponents.php(24): Livewire\\Features\\SupportPageComponents\\SupportPageComponents::renderContentsIntoLayout()
#36 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): Livewire\\Component->__invoke()
#37 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#38 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#39 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Routing\\Route->run()
#40 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#41 /ProjectPath/vendor/filament/filament/src/Http/Middleware/DispatchServingFilamentEvent.php(15): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Filament\\Http\\Middleware\\DispatchServingFilamentEvent->handle()
#43 /ProjectPath/vendor/filament/filament/src/Http/Middleware/DisableBladeIconComponents.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Filament\\Http\\Middleware\\DisableBladeIconComponents->handle()
#45 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#47 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#49 /ProjectPath/vendor/laravel/framework/src/Illuminate/Session/Middleware/AuthenticateSession.php(60): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\AuthenticateSession->handle()
#51 /ProjectPath/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#52 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#53 /ProjectPath/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /ProjectPath/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#55 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#56 /ProjectPath/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#57 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#58 /ProjectPath/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#59 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#60 /ProjectPath/vendor/filament/filament/src/Http/Middleware/SetUpPanel.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#61 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Filament\\Http\\Middleware\\SetUpPanel->handle()
#62 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#63 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\\Pipeline\\Pipeline->then()
#64 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(777): Illuminate\\Routing\\Router->runRouteWithinStack()
#65 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(741): Illuminate\\Routing\\Router->runRoute()
#66 /ProjectPath/vendor/laravel/framework/src/Illuminate/Routing/Router.php(730): Illuminate\\Routing\\Router->dispatchToRoute()
#67 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#68 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#69 /ProjectPath/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#70 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Livewire\\Features\\SupportDisablingBackButtonCache\\DisableBackButtonCacheMiddleware->handle()
#71 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#72 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#73 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#74 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#75 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#76 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#77 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#78 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#79 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#80 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#81 /ProjectPath/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#82 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#83 /ProjectPath/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#84 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#85 /ProjectPath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#86 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#87 /ProjectPath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#88 /ProjectPath/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle()
#89 {main}
"}

Also running artisan route:list I found next lines with "tenant" and "register" :

GET|HEAD  app/register ................................................................................................................................ filament.app.auth.register › Filament\Pages › Register

And in my app/Filament/App/Pages/Auth/Register.php (I copypasted it from some net docs :):

<?php

namespace App\Filament\App\Pages\Auth;

use Filament\Pages\Page;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Component;

class Register extends Page
{
    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected static string $view = 'filament.app.pages.auth.register';

    protected function getForms(): array
    {
        return [
            'form' => $this->form(
                $this->makeForm()
                    ->schema([
                        $this->getNameFormComponent(),
                        $this->getEmailFormComponent(),
                        $this->getPasswordFormComponent(),
                        $this->getPasswordConfirmationFormComponent(),
                        $this->getRoleFormComponent(),
                    ])
                    ->statePath('data'),
            ),
        ];
    }

    protected function getRoleFormComponent(): Component
    {
        return Select::make('role')
            ->options([
                'buyer' => 'Buyer',
                'seller' => 'Seller',
            ])
            ->default('buyer')
            ->required();
    }
}

Upvotes: 1

Views: 648

Answers (1)

Tom
Tom

Reputation: 860

The problem you're having is because your page is still a default page. Which means filament supposes you're logged in and will look for the required paremeters, in this case the "tenant" because of the multi tenancy.

By looking at the blog from laraveldaily, you see that he extends the page with a BaseRegister.

So by removing the $view and $navigationIcon and changing the inherits Page to BaseRegister it should work, see:

use Filament\Pages\Auth\Register as BaseRegister;
 
// Change this: class Register extends Page, to:
class Register extends BaseRegister 
{
    // remove: protected static ?string $navigationIcon = 'heroicon-o-document-text'; 
 
    // remove: protected static string $view = 'filament.pages.auth-register'; 

    protected function getForms(): array
    {
        return [
            'form' => $this->form(
                $this->makeForm()
                    ->schema([
                        $this->getNameFormComponent(),
                        $this->getEmailFormComponent(),
                        $this->getPasswordFormComponent(),
                        $this->getPasswordConfirmationFormComponent(),
                        $this->getRoleFormComponent(),
                    ])
                    ->statePath('data'),
            ),
        ];
    }

    protected function getRoleFormComponent(): Component
    {
        return Select::make('role')
            ->options([
                'buyer' => 'Buyer',
                'seller' => 'Seller',
            ])
            ->default('buyer')
            ->required();
    }
}

Upvotes: 2

Related Questions