Adding an action to a form in a livewire component not working

I have a livewire component with a form on it. I want to add a delete button, which I feel like should be pretty straight-forward. I see in the docs that I can add an anonymous action, but it's not clear on where I put it? Maybe this is obvious to others, but I've tried a few things: adding it to the mount method, using
registerActions
method on my form. I've tried following the instructions on adding it to a livewire component, including adding
{{ $getAction('myaction') }}
to the blade file, but that gives an error of
Undefined variable $getAction
.

How can I add an action button to a form (not a field) on a livewire component? I just want a simple delete button with a confirmation modal.

This is my form if it's helpful:

 public function editTaskForm(Form $form): Form
    {
        return $form->schema([
            TextInput::make('title')->required(),
            Textarea::make('description')->autosize(),
            Select::make('assigned_to')
                ->options(fn (): array => $this->task->team->members->pluck('fullName', 'id')->toArray())
                ->searchable()
        ])
            ->model($this->task)
            ->statePath('taskData');
    }


the action I'd like to add:

  Action::make('delete')
                ->action(fn (MonthEndTask $record) => $record->delete())
                ->requiresConfirmation()
Solution
public function deleteAction(): Action
{
  return Action::make('delete')
            ->requiresConfirmation()
            ->action(fn($arguments) => do something with arguments);
}


{{ ($this->deleteAction)(['id' => $record->id]) }}

<x-filament-actions::modals />
Was this page helpful?