How to mutate/format data for dehydration? (When using a custom field class)
Hi there, I know how to do this using the premade filament fields.
I created a custom field component. And it works great.
But I need to mutate the data that comes from the database so it display properly on my custom text field. Laravel returns back a custom cast object when accessing it from the database (not a singular raw string). So I need to be able to mutate that data to grab a single key from the array. otherwise nothing displays on the UI.
TLDR: how do i use the functionality of (formatStateUsing or dehydrateStateUsing) within a custom component class?
https://filamentphp.com/docs/3.x/forms/fields/custom#custom-field-classes
I've tried mutating the data within the setup() function but that doesn't work...
Thanks for your help!
1 Reply
Nevermind, figured out I need to use the hydrate method since that's what fills out the form.