Is there a unified place for mutateFormDataBeforeCreate() and mutateFormDataBeforeSave()?
I have some logic that I would like to run on both save and create for a specific field when it is being saved. Is there a unified place, for example in the resource class that runs on both new saves and on edit saves to keep code a bit cleaner?
8 Replies
I would just make a trait that can be applied to any create or edit record page.
Could potentially macro or globally configure the field type to handle the dehydrateStateUsing() modifier. But I think the trait would be safer unless you make a custom field.
I think you're right. A custom field may just be the way to go here though. This field is getting a little complex. Thank you @awcodes
Even if it’s custom, it can still extend an existing one too, so you don’t necessarily have to re-invent the wheel either.
I could extend the base Select field? If not too much to ask, are you aware of any docs on extending or projects that might do that, that I could source dive? That sounds like a fantastic option.
Check out my table repeater plugin it extends filament’s repeater with a few custom modifiers and a custom views but still uses all the default repeater class functionality.
GitHub
GitHub - awcodes/filament-table-repeater: A modified version of the...
A modified version of the Filament Forms Repeater to display it as a table. - awcodes/filament-table-repeater
But yea. It’s all just OOP
Based on what you’ve said you could probably just use the default view too.
I’d start with the setUp method on the fields and go from there.
You're amazing @awcodes , I really appreciate your help and time!