Trying to use the before method on the DeleteAction button

Hi, when I try to use the DeleteAction's before method and get the $this->record, I get the error "Using $this when not in object context", I followed the documentation in this page https://filamentphp.com/docs/2.x/admin/resources/deleting-records#halting-the-deletion-process
Filament
Deleting records - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
6 Replies
Tin
Tin2y ago
Can you share your code If you are trying to do $this in a resource, the error will be shown. Resources only describe how our pages are built So maybe you can use something from closure parameters to achieve what you want
Javier Mercedes
Javier MercedesOP2y ago
I tried the exact snippet on the table resource, this one if on an edit form, this one works, but the table doesn't
Javier Mercedes
Javier MercedesOP2y ago
@tin777 how can I get the selected record on the DeleteAction for the tables?, I haven't found it on the documentation
Tin
Tin2y ago
can you try putting $record instead of $action in your function parameters and use that something like before(function($record..... I think it should resolve the record also, are you in a resource or a page?
Javier Mercedes
Javier MercedesOP2y ago
The one that giving the error is a resource Is found it, if I call the $action->getModel() function I can get the selected item on the table
Strategic
Strategic16mo ago
Hi Kirito can you please advise share how did you use $action->getModel() inside before method? on the table to get the record (even based on your example) . thank you

Did you find this page helpful?