CreateAction and EditAction not triggering
I'm kind of lost where I should put my actions. I created a resource named Article by using php artisan make:filament-resource Article
I added my form fields etc. but now I want to trigger an action after the creation/edit of a resource. I tried appending(As described in the docs)
->mutateFormDataUsing(function (array $data): array {
$data['user_id'] = auth()->id();
return $data;
})
to the EditAction in my ArticleResource(table function) but that didn't work. What am I doing wrong?
1 Reply
mutateFormDataUsing
works if you are using simple modal resources
https://filamentphp.com/docs/3.x/panels/resources/getting-started#simple-modal-resources
If you are using pages, you should do this in Pages (CreatePage for example)
https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-data-before-saving