set required dynamically #12174
Unanswered
florian-bretz-pt
asked this question in
Q&A
Replies: 1 comment
-
I have the same question, It seems like once a rule is applied, even when the rules prop changes it is still somehow tracked |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have an issue which I'm not able to solve yet.
In my form, there are some input fields, which should be dynamically required, based on some other input, like a checkbox or a dropdown selection.
watch()
the checkbox to track its current state and use this value for the required state of Cfalse
, the required attribute seems to never get changed.trigger
which can revalidate input(s). The problem is, that this will validate the form immediately, showing the error, without me trying to submit the form. And the even bigger problem is, that even when I uncheck the box and fire the useEffect with thetrigger
the error remains for some reason.the question now is, how can I have rules dynamically rules applied on my inputs, for example required state depending on some other input and then revalidate the field (error) state when this other input has changed?
some example implementation:
Would be happy for any hints or help. ✌️
Beta Was this translation helpful? Give feedback.
All reactions