F
Filamentβ€’2y ago
bwubs

How to set multiple values from one form component

I have a form component that consists of two fields. But only one field is able to fill the state. Is it possible to get back two values for the state attribute of a custom field?
7 Replies
Dennis Koch
Dennis Kochβ€’2y ago
I think the only solution is using an array
bwubs
bwubsOPβ€’2y ago
as the value for state ?
Dennis Koch
Dennis Kochβ€’2y ago
Yes
bwubs
bwubsOPβ€’2y ago
thanks, i'll try that Thanks! It even works with object πŸŽ‰ Only thing is that the state now needs to be handled when saving the form. Is there a way the component can do this while dehydrating?
Dennis Koch
Dennis Kochβ€’2y ago
Via a cast?
bwubs
bwubsOPβ€’2y ago
i'm now looking if mutateDehydratedStateUsing is what i'm needing It needs to add two keys to the state and remove one. That's what i'm now doing in the code that handles the form submision. From what I understand mutateDehydratedStateUsing only gets the state of the component, not he whole form.
toeknee
toekneeβ€’2y ago
why not a cast on the model? you can get the whole form with $record.
Want results from more Discord servers?
Add your server