Change delete action type and position in edit form.
Hi there,
I need to change the delete action type to link and want to show it below the last form section on the edit form.
I have attached the snapshot of what I need.
I have got some what close to it but Delete action is not working.
Can someone help me with this?
Thanks in advance.
Solution:Jump to solution
```php
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('delete')
->requiresConfirmation()...
13 Replies
You need to make the action a functionable action:
and how can i hide it on create form?
Solution
Thank you again that worked for me.
on delete it says Can't set model as property if it hasn't been persisted yet
IF you try it with just 'delete' instead of my closure, does it work?
no it just opened confirmation pop up and on confirming it closes the pop up
Have a look at how the edit page adds the delete aciton, it should explain it
It uses Filament/Actions => DeleteAction for the default delete button.
I am unable to use it in Form Actions
this is what i get
That's because it's not part of the component, can you provide the code you are using
If it's 'delete' within the action, That would make sense. You probably need to adjust the action to get an id etc for the record to delete. I maybe use $livewire instead and $livewire->parent ?
this is the code I am using which throws above exception.
That likely will because you don't have a default function on the component you are calling ti from, that's why the action should ideally be an actual default action.
i.e. ->action(fn($data, $record) => dd($record))
should dump die the record with all the info, so you should be able to use standard model practices to delete the record.
Thanks but I just used the default action as link and placed it in the bottom of the form.