remix-validated-form
remix-validated-form copied to clipboard
[Feature]: Form `onFormChange` and accompanying hook.
What is the new or updated feature that you are suggesting?
I would like to have an onFormChange handler that is aware of all fields in the form. Currently there is no way to do this if you make use of custom components as they don't emit onChange events.
<ValidatedForm onFormChange={form => {
// can access the same values as the useFormContext hook
}}>
...
</ValidatedForm>
Why should this feature be included?
It makes it possible to do some things that aren't currently possible (ergonomically). In my case I want to submit the form every time it changes.
This seems reasonable. I think just having a useFormChange
hook is probably enough for a first pass. My thinking is we would listen to any regular change event or change to a controlled field and invoke the handler with the entire FormData
object. I'm not sure when I'll have time to get around to this, but I'm happy to provide guidance if you want try making a PR for this.
I really support this idea, for example I have a 'save' button and it would be reasonable for the button to be disabled if it is the same as the previous saved value. @airjp73 Is there a workaround currently for this?
RVF v6 has been released 🎉
This should be possible now using the subscribe api.
You can find the documentation here and the migration guide here.