This repository was archived by the owner on Jul 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Ability to specify excluded fields in useControlledΒ #698
Copy link
Copy link
Open
Description
Feature Request
We need to be able to exclude fields from the options of useControlled.
Describe the Feature
In a complex form with lots of subcomponents the place where you load the form values from the backend and set the default values on the form is in a different component than the fields.
The component where I do useForm({ defaultValues: { someSelect: 'foo' } }) has no idea how "someSelect" will be displayed (as a select / radios / input / etc).
In my case "someSelect" will be rendered with react-select meaning that I have a custom component using useControlled to wrap react-select. And it's in this custom wrapper where I need to tell the RCF to ignore the field.
There are 2 more reasons to consider implementing this change:
- if I ever change
react-selectto something else which doesn't require excluding anything I will have to change 2 components: the select wrapper component and the one with the useForm to remove the exclusion. - in a highly dynamic form where users can add new fields (
useFieldArrayfor example) it's very dirty (not DRY) to add logic to the component with useForm to exclude these dynamically added inputs.
Metadata
Metadata
Assignees
Labels
No labels