Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Dependent Dynamic Fields #313

Closed
mateuscardosogs opened this issue Sep 16, 2020 · 4 comments
Closed

Dependent Dynamic Fields #313

mateuscardosogs opened this issue Sep 16, 2020 · 4 comments

Comments

@mateuscardosogs
Copy link

Description of issue

I didn't find anything in the documentation reporting about it, so I decided to create the issue. The use case would be as follows:

I have a question form and I would like new questions to appear if the user marks a specific answer.

Usage example

I have the following question:

Do you have a car?
a) Yes
b) No

If the user checks the option a (Yes), a new question would appear:

What color is it?
Answer: Blue

If the user selects option b (No), a new question would appear:

Do you want to buy one this year?
a) Yes
b) No

And so on ...

It would be fields that depend on answers to appear.

@carlosallexandre
Copy link

Hey @mateusc42,

Are you requesting a new feature or want to know how to get what you describe?

@mateuscardosogs
Copy link
Author

@carlosallexandre In fact I would like to know if there is a possibility to do this action today and if it exists, I would like an example.

@carlosallexandre
Copy link

carlosallexandre commented Sep 30, 2020

@mateusc42,

You can do this with state. Maybe in the future we can have a custom hook useWatch (see the roadmap) that makes this easier.

I made a example here using useReducer

You could just do it with pure state, I was just trying a few things.
Let me know if it worked to you.

@mateuscardosogs
Copy link
Author

@carlosallexandre,

UseWatch would be of great help in these features.

Thanks for the answer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants