F
Filamentβ€’3mo ago
skyrowl

Form actions in custom Login page

Hey, I'm struggling to find the way to render the form with custom actions I saw the "getFormContentComponent" function but have no clue how to render it in a custom view Thx for any help!
Solution:
I have never tried that, what does the request logs state, if you change it to ->action('authenticate') does it work?
Jump to solution
13 Replies
skyrowl
skyrowlOPβ€’3mo ago
I'll need some help then please, I'm willing to render an action group with 2 actions When putting it at the end of the form and clicking on the authenticate action nothing happens Else I'm not sure how to render the group
toeknee
toekneeβ€’3mo ago
Provide your action code.
skyrowl
skyrowlOPβ€’3mo ago
public function form(Schema $schema): Schema
{
return $schema->components([
$this->getRoleLinksComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
Actions::make($this->getFormActions())
]);
}

protected function getFormActions(): array
{
return [
$this->getAuthenticateFormAction(),
$this->getRegisterFormAction(),
];
}
public function form(Schema $schema): Schema
{
return $schema->components([
$this->getRoleLinksComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
Actions::make($this->getFormActions())
]);
}

protected function getFormActions(): array
{
return [
$this->getAuthenticateFormAction(),
$this->getRegisterFormAction(),
];
}
authenticate action is from the base Login page from filament (the one not working) register action is a simple link
toeknee
toekneeβ€’3mo ago
The actual actions? without an ->Aciton() they will not do anything.
skyrowl
skyrowlOPβ€’3mo ago
can you elaborate please ? I'm not sure to understand filament is using this in the login page but I don't really know how to use it
public function getFormContentComponent(): Component
{
return Form::make([EmbeddedSchema::make('form')])
->id('form')
->livewireSubmitHandler('authenticate')
->footer([
Actions::make($this->getFormActions())
->alignment($this->getFormActionsAlignment())
->fullWidth($this->hasFullWidthFormActions()),
])
->visible(fn (): bool => blank($this->userUndertakingMultiFactorAuthentication));
}
public function getFormContentComponent(): Component
{
return Form::make([EmbeddedSchema::make('form')])
->id('form')
->livewireSubmitHandler('authenticate')
->footer([
Actions::make($this->getFormActions())
->alignment($this->getFormActionsAlignment())
->fullWidth($this->hasFullWidthFormActions()),
])
->visible(fn (): bool => blank($this->userUndertakingMultiFactorAuthentication));
}
toeknee
toekneeβ€’3mo ago
A filament action has an action i.e.
Action::make('delete')
->requiresConfirmation()
->action(fn () => $this->post->delete());
Action::make('delete')
->requiresConfirmation()
->action(fn () => $this->post->delete());
So it expets an actual action, quite often when no action(fn() => true) is set the action won't do anything. It's also work pointing out the form should be filled too if it's a create form. i..e $this->form->fill([]);
skyrowl
skyrowlOPβ€’3mo ago
Oh, it has ->submit('authenticate') Tho I'm using the function from the base Login page and it is protected, maybe that's why ?
toeknee
toekneeβ€’3mo ago
So you want to submit the form to 'authenticate' function?
skyrowl
skyrowlOPβ€’3mo ago
Yes that's it
Solution
toeknee
toekneeβ€’3mo ago
I have never tried that, what does the request logs state, if you change it to ->action('authenticate') does it work?
skyrowl
skyrowlOPβ€’3mo ago
Will tell you in some minutes changing it to an action instead of submit is working thx πŸ˜„
hashim199
hashim199β€’2mo ago
can we use passwordReset, registration ... method in custom login page ?

Did you find this page helpful?