Field Dependencies
Field dependencies refer to the relationship between fields in a form.
Field dependencies refer to the relationship between fields in a form. These dependencies are used to control the visibility, accessibility, or content of one or more form fields based on the value or selection of another field.
To use field dependencies, you must of course first ensure that your form has fields setup.
To show how field dependencies work in Onestop we are going to use a simple example:
We want to create 3 fields for a Burger ordering form. One called 'Extras', the other called 'Sauce' and the other called 'Cheese'.
Extras will have 2 choices: Cheese and Sauce.
When a user selects Cheese as the extra, the Cheese field should appear.
When a user selects Sauce as an extra, the Sauce field appears.
These are two dependencies.
To create the dependencies for this example, follow the steps below:
Create the 3 fields as drop down fields.
Choose the Options data source setting on the drop down field and then add options to each drop down field. For our case we will have:
Extras
Cheese
cheese
Sauce
sauce
Cheese
Mozarella
mozarella
Cheddar
cheddar
Sauce
Ketchup
ketchup
Chilli
chilli
Honey Mustard
honey_mustard
Its important to note that field dependencies will work with any type of data source, including local and remote datasets.
Once you have your fields setup, you are now ready to setup field dependencies.
Click on the "Field Dependencies" icon at the top right of the form builder.
The field dependencies interface appears as below:
Click on "Add New Field Dependency"
The field dependency form should appear.
As you can see, the form has 3 sections:
The dependency logic operator
This determines how the conditions should result in the dependency being applied to the form.
Leave the dependency to be applied if all conditions are met. For different business requirements, you can alternatively choose "any of the conditions are met"
Conditions
These are the conditions that will be trigger the dependency. Each condition you add should have:
A condition field: Any field that is set as a condition field, instantly becomes a controlling field in triggering the dependency.
A condition operator
A condition value.
Actions
These are the dependency actions that should be applied when the condition logic is met. Each action should have:
An action: The action can be one of 4:
Show dependent field
Hide dependent field
Restrict value of dependent field to preset values
Make dependent field required
A dependent field: The field to which the action will be applied.
So back to our example, we have 2 dependencies. Set them up as below:
Dependency 1
Conditions:
Field: Extras
Operator: Is Equal to
Value: Cheese
Actions:
Action: Show dependent field
Dependent Field: Cheese
Dependency 2
Conditions:
Field: Extras
Operator: Is Equal to
Value: Sauce
Actions:
Action: Show dependent field
Dependent Field: Sauce
You should now have 2 dependencies appearing as shown below. For both dependencies, 'Extras' is our controlling field.
Your form now has dependencies set based on the value given in the Extras field.
Last updated