-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
If a form field is ever switched to required, it will always be required #299
Comments
We found a related issue in RHF, hoping it can help, thanks! |
TextFieldElement
is ever switched to required, it will always be required
We found the root cause, RHFM passes the empty object as the rule and leads to the issue, please check the demo, thanks! https://codesandbox.io/p/sandbox/broken-cookies-38y28p |
@EkaLinMan, use unregister when changing the |
@sadik-malik, thanks for your reply, we overrode the But I'm afraid that the |
@EkaLinMan could you elaborate why providing your own rules is not the solution for this problem? I use the rules object in all my project because I need translated versions of the required error message anyway, that might be the reason why this issue was never present in my projects. To rely on required prop only is just a "lazy" shortcut. I am happy to review a PR though to fix it in your favour. |
Duplicates
Latest version
Current behavior 😯
Please check the demo, if the
TextFieldElement
orSelectElement
is ever switched to required, it will always be required even if the required state is switched back to false.Expected behavior 🤔
The
required
state of the form field should correspond to the real state passed from therequired
attribute.The text was updated successfully, but these errors were encountered: