onChange action. Once the value of the first dropdown list is
configured, the value of the second dropdown list will be updated automatically.
Linking dropdown lists example
This example incorporates two dropdown components: country and city. The city dropdown component’s options depend on the selected value of the country dropdown component. When the user selects a country, the options in the city dropdown should update accordingly:- Upon changing the value in the dropdown list of countries, the
onCountryChangeaction code is triggered. - The
Dataproperty, which represents the list of possible values for the city dropdown, is a computed field that assumes different values based on the value of the country field.
onCountryChange action is executed. Inside the action, the value of the city dropdown
is set to undefined. This ensures that the selected city is reset whenever the country changes. Here’s the code:
onCountryChange
onCountryChange action to the onChange event of the country dropdown, the action is automatically triggered whenever
the user selects a different country. This allows the city dropdown to be dynamically updated with the cities corresponding to the
selected country, creating a linked relationship between the two dropdowns.
When the value in country changes, the list of possible values in the city field is automatically recalculated. Here is the code of
the calculated field:
Next steps
- Explore all implementation guides: Guides hub
- Continue with runtime architecture: FormEngine Core
- Add visual form authoring: FormEngine Designer
- Integrate in your stack: Integrations
Official resources
- Runtime package: @react-form-builder/core on npm
- Designer package: @react-form-builder/designer on npm
- Source code and examples: FormEngine GitHub repository
- Commercial Designer plans: Pricing