T
TanStack•17mo ago
optimistic-gold

Is there a way to update the entire form's value at once, without touching the default value?

A specific user interaction will set the value of every field from state A to state B, and since there are a lot of them I'd like to do this with one operation. I'd also like to avoid touching the default values so that reset() can change them to the default state C.
2 Replies
optimistic-gold
optimistic-goldOP•17mo ago
FormApi.update would seem to be the right approach from the documentation, but it can only update default values/state, not necessarily the new values in state B.
xenial-black
xenial-black•17mo ago
A workaround could be something like this
form.store.setState((f) => ({
...f,
values: {
// your new values
},
}));
form.store.setState((f) => ({
...f,
values: {
// your new values
},
}));
But I don't think manually changing the store is good practice 🤔

Did you find this page helpful?