-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conditional field rendering #169
Comments
If you're using Here you can see you to work with the <Form onSubmit={...}>
{props => {
const values = props.form.getState().values
return (
<form>
<FieldOne />
{values.fieldOne === 'YES' && <FieldTwo />}
</form>
)
}}
</Form> For more examples. you can check out the list of examples on the official react final form page, it includes a "Conditional Fields" example. |
@Mohammer5 Thanks, It seems that react-final-form is some external library. Is there a way to do this using "https://ui-forms.dhis2.nu/?path=/story/checkbox--default" |
React final form is an external library, but it's bundled with the ui library. import { ReactFinalForm } from '@dhis2/ui`
const { Form, Field } = ReactFinalForm |
@Mohammer5 Thanks for your help. Can you please help me how to execute following scenario: I have created form using React final form as per your instruction. I have two select list field into that form let's say Region list and Province list. Now when I select any Region I want my province list options to get updated as per the selected Region. I will hit an API to fetch the province list options as the selected Region. So basically I want to update the option of Province field on change of Region field. Many thanks in advance for your help. |
@VijayAtDure You can use the Everytime the region is changes, you:
You can check out the docs about the You will need some kind of local state to store if you're loading data or not. Using the |
Can you please help me how to render conditional fields and validations.
Scenario:
The text was updated successfully, but these errors were encountered: