#setting initial form values

1 messages · Page 1 of 1 (latest)

velvet raptor
#

Hey @elfin latch ,

I have a form whose initial values would be dependent on certain conditions. What is the best way to implement this with mantine useForm hook (v 5.10.5)? Is there a way to change initial form values after it's been initialized or while initialization?

elfin latch
#

you can use form.setValues

#

do your fetch first then just overwrite it with that

#

if you want to set it up so you can "reset the form" to the fetched initialValues, older versions do not support this in the form object itself

#

you'd need to store that in separate state and then use form.setValues to "reset" it to the fetched values

dapper spear