F
Filament6mo ago
zsnake

Unable to find component: [app.filament.pages.auth.custom-login]

Livewire\Exceptions\ComponentNotFoundException Unable to find component: [app.filament.pages.auth.custom-login] this error happen when click sign in button its happen only when i replace default login with custom login CustomLogin.php
<?php

namespace App\Filament\Pages\Auth;

use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Auth\Login;
use Illuminate\Validation\ValidationException;

class CustomLogin extends Login
{
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getLoginFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}

protected function getLoginFormComponent(): Component
{
return TextInput::make('username')
->label('Username')
->required()
->autocomplete()
->autofocus()
->extraInputAttributes(['tabindex' => 1]);
}

protected function getCredentialsFromFormData(array $data): array
{
return [
'username' => $data['username'],
'password' => $data['password'],
];
}

protected function throwFailureValidationException(): never
{
throw ValidationException::withMessages([
'data.username' => __('filament-panels::pages/auth/login.messages.failed'),
]);
}
}
<?php

namespace App\Filament\Pages\Auth;

use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Auth\Login;
use Illuminate\Validation\ValidationException;

class CustomLogin extends Login
{
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getLoginFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}

protected function getLoginFormComponent(): Component
{
return TextInput::make('username')
->label('Username')
->required()
->autocomplete()
->autofocus()
->extraInputAttributes(['tabindex' => 1]);
}

protected function getCredentialsFromFormData(array $data): array
{
return [
'username' => $data['username'],
'password' => $data['password'],
];
}

protected function throwFailureValidationException(): never
{
throw ValidationException::withMessages([
'data.username' => __('filament-panels::pages/auth/login.messages.failed'),
]);
}
}
AdminPanelProvider.php
return $panel
->default()
->id('admin')
->path('admin')
->login(CustomLogin::class)
return $panel
->default()
->id('admin')
->path('admin')
->login(CustomLogin::class)
2 Replies
daniik
daniik4mo ago
@zsnake Did you resolve it?
Dennis Koch
Dennis Koch4mo ago
No sure whether Filament auto-registers the custom Login component for you. Maybe you need to use Livewire::component() to register it in a ServiceProvider I guess because it's in a Auth subfolder, Filament won't auto-discover it
Want results from more Discord servers?
Add your server