F
Filament14mo ago
tjodalv

Validate form from custom Action button - maybe bug

I've added custom action button on resource edit page and I want to validate form before proceeding with action. There is strange bug or weird behaviour. This is my action button:
class EditTask extends EditRecord
{
protected static string $resource = TaskResource::class;

protected function getHeaderActions(): array
{
return [
Actions\Action::make('Complete task')
->action(function () {
// I've found somewhere on discord that this validates form.
// It does but only the first time when this action is executed,
// if you click on the button again then empty modal is opened
// with two buttons Submit and Cancel ?!?
$this->form->getState();

// after validation form should be saved
$this->save();

// the rest of action code should be here
}),
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}
}
class EditTask extends EditRecord
{
protected static string $resource = TaskResource::class;

protected function getHeaderActions(): array
{
return [
Actions\Action::make('Complete task')
->action(function () {
// I've found somewhere on discord that this validates form.
// It does but only the first time when this action is executed,
// if you click on the button again then empty modal is opened
// with two buttons Submit and Cancel ?!?
$this->form->getState();

// after validation form should be saved
$this->save();

// the rest of action code should be here
}),
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}
}
1 Reply
tjodalv
tjodalvOP14mo ago
When action 'Complete task' is clicked first time, form is being validated and error messages appear under fields that are not valid, but if I click on the action button again, then modal window gets opened with heading 'Complete task' and buttons 'Submit' and 'Cancel'. Why is that?
Want results from more Discord servers?
Add your server