Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Ability to specify excluded fields in useControlled #698

Open
terebentina opened this issue Jul 22, 2021 · 0 comments
Open

Ability to specify excluded fields in useControlled #698

terebentina opened this issue Jul 22, 2021 · 0 comments

Comments

@terebentina
Copy link

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:

  1. if I ever change react-select to 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.
  2. in a highly dynamic form where users can add new fields (useFieldArray for example) it's very dirty (not DRY) to add logic to the component with useForm to exclude these dynamically added inputs.
@wellyshen wellyshen linked a pull request Jul 24, 2021 that will close this issue
@wellyshen wellyshen removed a link to a pull request Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant