F
Filamentβ€’16mo ago
guilebc

headerActions: "mutateFormDataUsing" method not working in RelationManager table

Context: I'm in a RelationManager, I want to add a CreateAction::make() button in "headerActions" at the "table" method. I also use "spatie-laravel-translatable-plugin" The following code below (cf. screenshot) does not work. The "mutateFormDataUsing" method for modifying the data on save is not taken into account. Any idea or is this a bug? Thank you for your help.
Solution:
Probably there's a Page Action which has the same name. Action names must be unique.
Jump to solution
7 Replies
DariusIII
DariusIIIβ€’16mo ago
I am using same function and i had the same issue, altered data was not taken in account. So i just alter data directly inside the function and save it before returning it back.
guilebc
guilebcOPβ€’16mo ago
Ho ok, but in my case it's really strange because for example this code is not even executed. The only difference for the moment with your code is that I am using CreateAction and not EditAction.
guilebc
guilebcOPβ€’16mo ago
I just tried on an Edit Action button, it actually works, the method is called correctly. This is therefore a problem on the CreateAction. In any case, thank you @dariusiii for your very informative feedback.
Carlo
Carloβ€’16mo ago
I'm having the same problem and yes it does work in EditAction but not in CreateAction. Have you made any workaround? Not sure why, but if I'm only using CreateAction::make() the ->mutateFormDataUsing() is not being called but if I pass a string name to CreateAction::make('New Resource') it works.
Dennis Koch
Dennis Kochβ€’16mo ago
Do you have a duplicate action? πŸ€”
Solution
Dennis Koch
Dennis Kochβ€’16mo ago
Probably there's a Page Action which has the same name. Action names must be unique.
Carlo
Carloβ€’16mo ago
I see, I do have a CreateAction inside emptyStateActions and headerActions so it's kinda duplicated. I tried removing the other action inside emptyStatections so now it's working, the mutateFormDataUsing() is now being triggered. Thanks for the answer πŸ™‚
Want results from more Discord servers?
Add your server