F
Filament5mo ago
o.m

How do I properly add save button to form?

public function form(Form $form): Form
{
return $form
->schema([
Section::make('Sent to existing users when they get added to a new group')
->description('Add User Group')
->schema(
collect($this->notification['options'])->map(function ($option) {
return RichEditor::make("formData.{$option['slug']}")
->label($option['name'])
->required()
->columnSpanFull();
})->toArray()
),
View::make('filament.pages.components.edit-notification-footer'),
Action::make('update')
->label('Update')
->requiresConfirmation()
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Sent to existing users when they get added to a new group')
->description('Add User Group')
->schema(
collect($this->notification['options'])->map(function ($option) {
return RichEditor::make("formData.{$option['slug']}")
->label($option['name'])
->required()
->columnSpanFull();
})->toArray()
),
View::make('filament.pages.components.edit-notification-footer'),
Action::make('update')
->label('Update')
->requiresConfirmation()
]);
}
This is my form function and I get this error Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, Filament\Forms\Components\Actions\Action given How do I properly make a save button for the form? adding Action::make causes an error
8 Replies
o.m
o.mOP5mo ago
No description
ChesterS
ChesterS5mo ago
Lmao my brother in christ, what is that form? You've got everything mixed up. I suggest you go back to the docs because you've confused a lot of things. FWIW, here is a sample custom page form
<form wire:submit="submit">
{{ $this->form }}

<x-primary-button type="submit" class="mt-4 relative">
{{__('Save')}}
</x-primary-button>
</form>
<form wire:submit="submit">
{{ $this->form }}

<x-primary-button type="submit" class="mt-4 relative">
{{__('Save')}}
</x-primary-button>
</form>
Also, to get rid of the error, change your form to this
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Sent to existing users when they get added to a new group')
->description('Add User Group')
->schema(
collect($this->notification['options'])->map(function ($option) {
return RichEditor::make("formData.{$option['slug']}")
->label($option['name'])
->required()
->columnSpanFull();
})->toArray()
),
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Sent to existing users when they get added to a new group')
->description('Add User Group')
->schema(
collect($this->notification['options'])->map(function ($option) {
return RichEditor::make("formData.{$option['slug']}")
->label($option['name'])
->required()
->columnSpanFull();
})->toArray()
),
]);
}
o.m
o.mOP5mo ago
Sorry about that, still quite new with this one, trying my best how to use this but I often really get confused. Thanks for this sample. Maybe I should try keeping the view organized. Most of my answers also came from like other peoples samples from the websearch/forums hehe
ChesterS
ChesterS5mo ago
I suggest you focus on the docs when starting, the examples there are simple and straightforward
o.m
o.mOP5mo ago
Should this be on the view file? Just confused because I often use this syntax in the view.
<x-filament-panels::page>

<x-filament-panels::page>

ChesterS
ChesterS5mo ago
Yes, a more complete example would be something like this
<x-filament-panels::page>
<x-filament-panels::form
:wire:key="$this->getId() . '.forms.' . $this->getFormStatePath()"
wire:submit="save"
>
{{ $this->form }}
</x-filament-panels::form>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament-panels::form
:wire:key="$this->getId() . '.forms.' . $this->getFormStatePath()"
wire:submit="save"
>
{{ $this->form }}
</x-filament-panels::form>
</x-filament-panels::page>
o.m
o.mOP5mo ago
Where can I read a documentation about calling the right component <x-filament-panels::page> or <x-filament::section>. or <x-filament-panels::page> sometimes I see this <x-filament::section> and get confused with this one why others have -panels>

Did you find this page helpful?