form-js
form-js copied to clipboard
Make it possible to change form data after first render
Is your feature request related to a problem? Please describe
On Zeebe Tasklist if we try to complete a Task that was already completed we receive the updated Task and update the values on the form. To do that we need a way to update the values after the first render.
Describe the solution you'd like
const form = createForm({
// ...
});
form.setData(newData);
// or
form.setProperty('data', newData)
Additional context
Currently I'm using form.setState({ data })
for that, but I assume that it's not public API and not very wise to use it on long term
What is the expectation regarding the dirty state in such scenario? Is the dirty state reset? Is the dirty state updated, i.e. does it act like a bulk edit?
I would assume we reset the dirty state, even though that's not important for us because on this specific case we'll set the form to readOnly
mode after changing the value.
On other libraries to manage forms that I have experience using, like react-final-form
, they reset the form meta state but allow an option to keep dirty on reinitialize
What is the dirty state of a form (viewer)? Are you referring to the errors being displayed?
What is the dirty state of a form (viewer)? Are you referring to the errors being displayed?
The dirty state is a flag to signal if the current values of the form is different than the values the form was initialized with.
At least it is with other form libraries I have used like react-final-form
and formik
.