How to handle dynamic forms? #273
-
Let's say I have a checkbox "Other: Provide reason" and when checked, a text field becomes enabled and the user must enter a reason into it. And when the checkbox is unchecked I want to clear out the reason text field since it only applies when the checkbox is checked, so I don't want its value being included in the form submission. Another scenario would be a user picks a country on an address form and then different fields appear based on the locale, i.e. US would have state and zip code, but other countries might have different things like districts, departments, prefectures, etc... so I need a dynamic set of fields to appear as the user is entering data. I've used react-hook-form for a little while and I'd use My guess would be that I need to make a Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Conform does not manage the form data as RHF does and it validates simply by looping over each entry on the FormData object. So what you said is pretty much correct: Just manage them with a simple |
Beta Was this translation helpful? Give feedback.
Conform does not manage the form data as RHF does and it validates simply by looping over each entry on the FormData object. So what you said is pretty much correct: Just manage them with a simple
useState
and call it a day :)