Need the options in a select list to change based on the value selected in a different field? Field relations' got you covered. You can do this, and you can also control an entire field and field group.
Overview
There are three different types of custom field relations that can be used in both listing and review forms:
- Field Option → Field Option
- Field option → Field
- Field option → Field group
The relations are establihed in the target field option, field or field group by specifing the Control Field
and Control Value
. In other workds, we tell the option, field and field group that it will be become active and visible only when the control field + value is selected.
The are many different ways to setup relations, from very simple to highly complext. We recommend you try to keep things on the side of simple.
The Initial Setup article has a section on Custom Field Relations that includes more detailed examples and video tutorials.
Field Option → Field Option
This relation allows changing the available options in a select field when an option is selected in another field (select, checkbox, radiobutton). One example where this type of relation is useful is when working with Country, State and City custom fields.
The relationship is defined in the Controled By
section of the dependend field option using the Control Field
and Control Value
settings.
For example, to create a Country → State
, you would add each State option individually to the State custom field, and for each option set the Control Field
and Control Value
.
Using the United States to illustrate the setup, when you create the State options the settings would be:
- Control Field:
jr_country
- Control Value:
united-states
Only one control field can be chosen, but it's possible select multiple control values in that field, so that if any of the control field values is selected in the control field, the option becomes visible.
Dependent fields need to be placed in a specific order. In the above example, when you view the form, the Country
field must be visible above the State
field. When a country is selected, the State field displays below it.
Field Option → Field
This relation allows toggling an entire field, of any type, when a field option is selected in another field (select, checkbox, radiobutton).
The relationship is defined in the Controled By
section of the dependend custom field using the Control Field
and Control Value
settings.
It can be useful when you need to display certain fields only when an option is selected in another field. For example if you have a Business Category
custom field, you can display different fields for each business category depending on the business selected.
Using this approach can allow simplifying the Joomla and WordPress category structure if you are able to use the same listing type for all business listings. This will depend on whether they can share the same rating criteria and settings.
Field Option → Field Group
This relation allows toggling an entire field group when a field option is selected in a field (select, checkbox, radiobutton).
The relationship is defined in the Controled By
section of the dependend field group using the Control Field
and Control Value
settings.
This relation has a similar use as the Field Option → Field Option
relation, but allows you to group several fields together in a field group rather than having to create individual field relations.