Replies: 3 comments 1 reply
-
|
I also hit this issue. I set the I wanted to use the I believe the developers know there is a problem, because I don't see any documentation on the |
Beta Was this translation helpful? Give feedback.
-
|
I tried this, and it works. |
Beta Was this translation helpful? Give feedback.
-
|
It looks like the disabled prop on Controller isn’t meant to toggle the input state directly. It mainly tells React Hook Form to skip updates and validation for that field once it’s disabled, which explains why the form values become out of sync when you use it this way. When you pass Your workaround with
is the right approach if your goal is just to make the inputs read-only during submission. That way, the UI reflects the disabled state, but React Hook Form still keeps the field registered and its value intact. So in short: The disabled prop in Controller is more for controlling whether React Hook Form should manage that field, not for UI disabling. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So I initially did the following:
This will cause the form values to be set to
undefinedafter 1st submission. However, thefield.valueseems to be unaffected. So it creates a weird scenario of the displayed value being valid but the form doesn't pass validation on subsequence submissions. And when typing in the field, let's say the displayed value is "abc" and I type "d". The displayed value will become "abcd", but the form value, i.e. the actual value that will be submitted, is just "d".Now this can be worked around in the following manner:
But this makes me wonder,
disabledprop inController?Beta Was this translation helpful? Give feedback.
All reactions