How to set up dependent fields in your form?
Dependent fields allow you to manage sets of dependencies between fields. When a field is dependent, it will only be available for editing and displayed if the state of the parent field satisfies the right rule set by you. If the rule is not satisfied, it will not be possible to view or edit dependent form fields. Note that the first form field can’t be dependent.
Note: If the rule is not satisfied, the dependent field will not be visible in the MDC.
There are various rules that can be activated for the form item:
- All of these rules need to be satisfied.
- At least one rule needs to be satisfied.
- Exactly one rule should be satisfied.
- None of the rules can be satisfied.
The dependency expressions can be set based on the following operators:
- have a value – the parent field has to have any value in order to display the dependent field.
- contain – the parent field has to contain the value defined in the dependent field in order to display the dependent field. This operator is case sensitive.
- be less than – the value in the parent field has to be less than the value in the dependent field (works only with numeric fields).
- be less or equal to – the value in the parent field has to be less or equal the value in the dependent field (works only with numeric fields).
- be equal to – the value in the parent field has to be equal to the value in the dependent field.
- be more or equal to – the value in the parent field has to be more or equal to the value in the dependent field (works only with numeric fields).
- be more than – the value in the parent field has to be more than the value in the dependent field (works only with numeric fields).
It is only possible to define dependencies for the form items above the dependent field because they branch from the parent field. It is possible to set more dependencies for one form field.
After choosing a rule, you can choose form fields included, condition, condition value and add another dependency.
Besides adding depedent fields on form items, you can add dependent fields on value items as well.
Example 1
We want to collect data about buildings. Only if the building is a hotel, we want to take a picture of it. Only if the building is a hospital, we want to collect addresses.
1. Set “parent” field (in this example Building).
2. Add a new Photo field and click the Dependencies button. This form field will be dependent on the “Building” form field. Set conditions and enter the value.
Note: This form field will be visible in the MDC only if the value in the “Building” field is equal to “Hotel”.
3. To collect address data only for hospitals, we have to add a new dependency field. Add a new text field and click the Dependencies button.
Note: This form field will be visible in the MDC only if the value in the “Building” field is equal to “Hospital”.
The changes in Mobile Data Collection Portal should be automatically saved.
Example 2
We want to collect data about traffic signs. If the sign material is Acrylic and watercolor, Thermoplastic or Cold plastic we want to display the photo field.
1. Set the parent field as a checkbox form item and define values (in this example Sign Material).
2. Add a new Photo field and click the Dependencies button. This form field will be dependent on the Sign Material form field.
3. Select ‘contain’ operator and enter value defined in the Sign Material field.
4. Select the rule which defines when the dependent field will be visible.
5. The changes should be automatically saved. Open MDC and select some of the values in the checkbox field. The dependent field should appear based on the defined dependencies.
Example 3
We want to collect data about traffic signs. If the traffic sign ID contains the value ‘BB7’, we want to open an additional field for notes in the form.
1. Set the parent field as a text form item and give it a name (in this example, Sign ID).
2. Add a new text field and click the Dependencies button. This form field will be dependent on the Sign ID form field.
3. Select ‘contain’ operator and enter the value when the dependent field will be visible (in this example ‘BB7’).
Note: ‘contain’ operator checks if the part of dependent field’s value has the value defined in the parent field e.g., if the parent value is defined as BB7, the dependant field will be visible if in the parent field is written e.g. BB7a1234 or a1234BB7
4. Select the rule which defines when the dependent field will be visible.
5. The changes should be automatically saved. Open MDC and insert the value in the Sign ID field. The dependent field should appear based on the defined dependencies.