field-form
field-form copied to clipboard
Propogate Fields state to Form
What problem does this feature solve?
It allows to get the current state of form (touched
, valid
) without iteration among all fields.
There are multiple use-cases:
- block submit button until form is valid
- block application state if there are any invalid fields
- disable auto-save to prevent invalid data from saving on backend for editing
What does the proposed API look like?
I expect FormInstance to have methods/props isValid
(are all fields valid), isTouched
(is any field touched)
The similar approach is implemented among such libraries as
- Formik https://jaredpalmer.com/formik/docs/overview
- angular's ReactiveForms https://angular.io/api/forms/FormGroup
- react-final-forms https://final-form.org/docs/final-form/types/FormState
Proposed API: I've used antd for example, if it's not ok I can update with plain rc-field-form
const FormComponent = () => {
const [form] = Form.useForm()
return <Form form={form}>
<Button htmlType="submit" disabled={!form.isValid()}>Ok</Button>
</Form>
}
Any status? I think it's a useful feature.
Almost 3 years later, and I would love to have this
This would be great to have.