How to add two Create Form Actions

I have a resource and inside create page I am defining create form action in header actions. But the action does not work for some reason, however the default form action works as expected. following action does not work:
class CreateCategory extends CreateRecord
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction(),
];
}
}
class CreateCategory extends CreateRecord
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
$this->getCreateFormAction(),
];
}
}
Am i missing something or doing something wrong here?
4 Replies
Lara Zeus
Lara Zeus16mo ago
Maybe they both have the same name? 'create" what the function getCreateFormAction will return?
Mansoor Khan
Mansoor KhanOP16mo ago
ah let me try changing the name. good point.
what the function getCreateFormAction will return?
It was using the action from Filament:
protected function getCreateFormAction(): Action
{
return Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create')
->keyBindings(['mod+s']);
}
protected function getCreateFormAction(): Action
{
return Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create')
->keyBindings(['mod+s']);
}
I have changed the Create page to following but does not work:
class CreateCategory extends CreateRecord
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('create_2')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),
];
}
}
class CreateCategory extends CreateRecord
{
protected static string $resource = CategoryResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('create_2')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),
];
}
}
I tried this and it works.
Action::make('create_2')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->action(fn () => $this->create()),
Action::make('create_2')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->action(fn () => $this->create()),
Seems like we cant use ->submit('create') another place?
Lara Zeus
Lara Zeus16mo ago
are you adding create btn in a create page? submit('create'), I think create is the name of the livewire action so you have to pass your function name
Mansoor Khan
Mansoor KhanOP16mo ago
Yes, i need the create action (which saves/submits the form) in a real large form. So for the easiness i need it in both header and footer Understood. I wish i could use the same action.
Want results from more Discord servers?
Add your server