EditForm - can't submit form action on set on form header actions

<?php

namespace App\Filament\Resources\FormResource\Pages;

use App\Filament\Resources\FormResource;
use App\Models\Form;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Filament\Support\Colors\Color;

class EditForm extends EditRecord
{
protected static string $resource = FormResource::class;

protected function getHeaderActions(): array
{
return [
$this->getCancelFormAction()->icon('heroicon-o-backspace'),
Actions\DeleteAction::make()->icon('heroicon-m-trash'),
$this->getSaveFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal), // ⚠️ here doesnt save??? what
];
}

protected function getFormActions(): array
{
return [
$this->getSubmitFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal), // ⚠️ here yes
//
];
}
}
<?php

namespace App\Filament\Resources\FormResource\Pages;

use App\Filament\Resources\FormResource;
use App\Models\Form;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Filament\Support\Colors\Color;

class EditForm extends EditRecord
{
protected static string $resource = FormResource::class;

protected function getHeaderActions(): array
{
return [
$this->getCancelFormAction()->icon('heroicon-o-backspace'),
Actions\DeleteAction::make()->icon('heroicon-m-trash'),
$this->getSaveFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal), // ⚠️ here doesnt save??? what
];
}

protected function getFormActions(): array
{
return [
$this->getSubmitFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal), // ⚠️ here yes
//
];
}
}
if i click on the submit form action (form action) it saves the data if i click on the submit form action (header action) it does nothing objective: save the data in the header actions too
2 Replies
Daniel Plomp
Daniel Plomp14mo ago
Like to know this as well. Or maybe how to 'move' the save button from the bottom to the top. @joe I was able to achieve this by the following code on e.g. my EditPage. The requiresConfirmation is of course optional.
protected function getHeaderActions(): array
{
return [
$this->getSaveFormAction(),
DeleteAction::make(),
ForceDeleteAction::make(),
RestoreAction::make(),
];
}

protected function getSaveFormAction(): Action
{
return Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->requiresConfirmation()
->action(fn () => $this->save())
->keyBindings(['mod+s']);
}
protected function getHeaderActions(): array
{
return [
$this->getSaveFormAction(),
DeleteAction::make(),
ForceDeleteAction::make(),
RestoreAction::make(),
];
}

protected function getSaveFormAction(): Action
{
return Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->requiresConfirmation()
->action(fn () => $this->save())
->keyBindings(['mod+s']);
}
ericmp #2
ericmp #2OP13mo ago
thank u! @Daniel Plomp so just copied the function from the vendor to the editform right? oh now im having the same issue but in the CreateForm im trying this:
<?php

namespace App\Filament\Resources\FormResource\Pages;

use App\Filament\Resources\FormResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Filament\Support\Colors\Color;

class CreateForm extends CreateRecord
{
protected static string $resource = FormResource::class;

protected static bool $canCreateAnother = false;

protected function getHeaderActions(): array
{
return [
$this->getCancelFormAction()->icon('heroicon-o-backspace'),
$this->getCreateFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal),
];
}

protected function getFormActions(): array
{
return [
//
];
}

protected function getCreateFormAction(): Actions\Action
{
return Actions\Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create')
->keyBindings(['mod+s'])
;
}
}
<?php

namespace App\Filament\Resources\FormResource\Pages;

use App\Filament\Resources\FormResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Filament\Support\Colors\Color;

class CreateForm extends CreateRecord
{
protected static string $resource = FormResource::class;

protected static bool $canCreateAnother = false;

protected function getHeaderActions(): array
{
return [
$this->getCancelFormAction()->icon('heroicon-o-backspace'),
$this->getCreateFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal),
];
}

protected function getFormActions(): array
{
return [
//
];
}

protected function getCreateFormAction(): Actions\Action
{
return Actions\Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create')
->keyBindings(['mod+s'])
;
}
}
but doesnt work any ideas why it doesnt work? im just doing the same as edit, but for create, but when i click the create button to store, it doesnt do anything i also tried to put this line inside the getFormActions fn
$this->getCreateFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal),
$this->getCreateFormAction()->icon('heroicon-m-cloud-arrow-down')->color(Color::Teal),
and this line, inside the getFormActions fn works, but inside the getHeaderActions fn doesnt why? what i am missing? 🤔 hi daniel, ive found an issue with this. if the button is in getHeaderActions fn. if u r uploading a file, u can click the button instead, if the button is in getFormActions, u cant click the button - which is how should act

Did you find this page helpful?