Page with multiple forms action
Hello, i am making a page that have multiple forms in it, how do i have an action for each form's submit ?
14 Replies
i will post what i have tried so far soon
If it's a custom page, you would ideally have multiple livewire components each being a form so it' calls it'self
protected function getForms(): array
{
return [
'generalInfoForm' => $this->makeForm()
->schema($this->getGeneralInfoFormSchema()),
'passwordForm' => $this->makeForm()
->schema($this->getPasswordFormSchema())->statePath('passData'),
'configForm' => $this->makeForm()
->schema($this->getConfigFormSchema()),
];
}
protected function getPasswordFormSchema(): array {
return [
LovaSection::make('Change Password')
->compact()
->collapsible()
->collapsed()
->columns(3)
->schema([
TextInput::make('current_password')
->label('Current Password')
->password()
->rules(['required_with:new_password'])
->currentPassword()
->autocomplete('off'),
TextInput::make('new_password')
->label('New Password')
->password()
->rules(['confirmed'])
->autocomplete('new-password'),
TextInput::make('new_password_confirmation')
->label('Confirm Password')
->password()
->rules([
'required_with:new_password',
])
->autocomplete('new-password'),
])
->footerSchema([
DropInAction::make('password_action')->disableLabel()
->execute(
\Filament\Forms\Components\Actions\Action::make('passwordAction')->action('update_password')
)
])
];
}
hello, thank you for quick response, do you mean to make <livewire:form> on the page file ? instead of inside classNo you would build individual livewire components if you want them to have different form actions completely.
so.. what is the point of getForms() then ?
i mean, what is the use case
for a page with multiple forms, but still have 1 action ?
Ahh my bad, I am not familiar with getForms. Just checked the docs one second
ah okay, i will complete my question first, the Action in my code would not call the update_password public function, and that confuses me
Makes sense now, you would need to customise the view to have an action on the form. So for example:
https://filamentphp.com/docs/2.x/forms/getting-started#using-multiple-forms
you would have
I believe, but along those lines
Filament
Getting started - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
i had hoped that it didnt come to that.. hahaha, because i want to use the styling of filament's components
so its not possible to make the submit button in the form schema ?
i feel like i am so close with my approach to use drop-in-action as the submit button for my forms, any insights as to why the action button in my code is not working ?
Why not make a
function()
in the ->action()?hello, i have also tried that, like this
DropInAction::make('password_action')->disableLabel()
->execute(
function (\Closure $get, \Closure $set){
return \Filament\Forms\Components\Actions\Action::make('geolocate')
->icon('heroicon-o-search')
->label('Geocode')
->action(function () use ($get,$set){
Log::info('asdasdasd');
$set('subscriber_code', 'asdasd');
});
}
)
but nothing is in the logThat's weird
Did you try dd()?
Also i'm not sure if $get and $set are closures
yes i just tried dd()
and the response is still 200, with these
{
"effects": {
"html": null,
"dirty": []
},
"serverMemo": {
"checksum": "d01bfee9a651579cda0a6b6d919a641ed10be0f0da664f116ca9ddeaf07cfee5"
}
}
nothing happened
as if it didnt reach the dd() at allDo you have any errors in your code editor? And what is the rest of the code from the form builder