Cascading Choices
Often the answer to one Choices field should populate or filter the options available in a subsequent field.
We call this "cascading choices", where a parent Choice drives one or more child fields.
You can easily add cascading behavior using the Form Designer.
Our platform is smart enough to handle many levels of cascading choices too - i.e. where one field filters another, which in turn filters another etc.
Note that you must be using a Data Source for your child field(s) in order to add cascading functionality to your Form. We recommend using Data Sources on all your Choices fields - it is a simpler approach and means that common lists of options such as "Yes/No" can be shared and reused across fields and Forms.
Let’s assume we want the following cascading behavior:
Country field
--> State field
So when the user choses a country, then the State field should only show states for that selected country.
Now let’s assume the State and City Data Sources are as follows:
Country Code | Country Name |
---|---|
AU | Australia |
etc.. | etc.. |
US | United States |
State | State Name | Country Code |
---|---|---|
NSW | New South Wales | AU |
QLD | Queensland | AU |
WA | West Australia | AU |
AL | Alabama | US |
AK | Alaska | US |
The steps to implement cascading behavior using the above example data and setup is as follows:
- In the Form designer, add a Choices field and name it Country.
- Select the Country field - this will show the properties for the field on the right hand side.
- Find the property titled "Answer Choices" and select "Data Source".
This will show a bunch of options for Data Sources.
- In the drop down list of available Data Sources, find the Countries Data Source and select it.
Sweet! At this stage your Country field will now show a list of countries as defined in the Countries data source.
Now let’s hook up the State field, along with its cascading filter! - Add another Choices field and name it State.
- Repeat steps 2 - 4 on your State field, this time round you want to select the States data source.
- While still on the State field's properties, you should see a "add filter" link just below the data sources drop down.
Click this link to add a new filter. - You'll now see three fields displayed that let you define how the filter should work.
What we want to do is have the rows in the States data source be filtered according to the Country Code selected in the Country field.
- The first filter drop down shows the columns available on the States data source.
Choose the "Country Code" option.
- The second filter drop down shows the logical operations we can use for filtering.
Choose the "equals" option.
- The third field is a text field where you can enter the name of another field or just a static value.
We want to filter by the Country field's answer, so enter {{Country}} into the text box.
Awesome, you're done :)
Now if you save the Form and set it to be in Test mode, you can try it out on your device.
You should see that once you choose a country, the State field is automatically filtered to only show the States rows that have Country Code = the selected country.