TanStackT
TanStack5mo ago
12 replies
clean-aquamarine

Partial reset of a modified form

Hello! I have a question relative to form reset and defaultValues.

Right now, I have a form that gets async initial values through TanStack Query, and it's working just fine. It even updates the defaultValues when the data changes, perfect.

The important detail though, is that if the form is touched, the defaultValues will not be updated anymore. It makes total sense, you wouldn't want to override the changes made by the user.

But would there be a way to detect which fields have been modified and which ones haven't, so we could still update the fields that the user didn't modify with the new data?

The main scenario is for multi-user forms, where a user might update a bunch of fields, and we would like to propagate these changes to the other users, without losing their current changes.
Was this page helpful?