Skip to content

Make useController disabled flag optional / configurable #289

@larsinho81

Description

@larsinho81

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

Hej,

The components internally integrate with react hook form state using the useConroller hook, like this:
const { field, fieldState: { error } } = useController({ name, control, disabled: rest.disabled, rules: rulesTmp });

In our project, using the disabled flag causes two kinds of problems:

  1. The formState.isDirtyFlag is always true*
  2. The values of the disabled fields are not included on submit

Which breaks a lot of functionality. We may be able to work around it in a bigger refactoring, but it would be ideal if there was the option to opt out of this behaviour, like a flag for example "registerDisabled=true" which can be disabled on component configuration and then the useController would be intiialized without the disabled flag.

`* That seems to be related to this:
react-hook-form/react-hook-form#4740

PS:
I can help work on a pull request if you are willing to consider this feature. Thanks!

Examples 🌈

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions