mutateFormDataBeforeCreate vs dehydrateStateUsing

Are they kind of interchangeable? I understand that one is specific to create, but in general, couldn't dehydrateStateUsing() be used instead to transform data before saving so that most of your logic is right there at the form field creation?
2 Replies
Dan Harrin
Dan Harrin2y ago
yes dehydrateStateUsing() is better in lots of cases because it can be reused between forms
wyChoong
wyChoong2y ago
dehydrateStateUsing() is only for transforming the field itself only mutateFormDataBeforeCreate you can add values into $data for creation, eg: $data[‘user_id’] = auth()->user()->id
Want results from more Discord servers?
Add your server