Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine checkbox group by defaultValues when using useController #8430

Closed
giovannipiller opened this issue May 31, 2022 · 2 comments
Closed
Labels
feature request request a feature to be added waiting-up-vote Waiting for votes from the community.

Comments

@giovannipiller
Copy link

On version 7.30.0 it has been added support for determining checkbox group based on the defaultValues (#7938).

This however seems to be limited fields created via register(...) -> https://codesandbox.io/s/rhf-register-oef6f9-oef6f9

There are two more scenarios that would be nice to cover:

  1. Setting up the field defaultValue via useController:
  const myField = useController({
    control,
    name: "firstName",
    defaultValue: []
  });
  1. using useController rather than register to setup the field:
  const { handleSubmit, control } = useForm<FormValues>({
    defaultValues: { firstName: [] }
  });

  const myField = useController({
    control,
    name: "firstName",
  });

Any thoughts?

@giovannipiller giovannipiller added feature request request a feature to be added waiting-up-vote Waiting for votes from the community. labels May 31, 2022
@bluebill1049
Copy link
Member

hey, @giovannipiller for the controlled components you could host your own local state, Controller or useController just a headless component or hook to collect and validate data. The same reason some of the additional props is not migrate to controlled, because when you build a controlled component, you are having the control already.

@giovannipiller
Copy link
Author

Ok, thanks for the reply!

@giovannipiller giovannipiller closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request request a feature to be added waiting-up-vote Waiting for votes from the community.
Projects
None yet
Development

No branches or pull requests

2 participants