Nuxy
Search…
Fields dependency
This option serves to define the dependency of different fields. It shows the connections of various fields and indicates the changes in the values of options.
It’s critical to understand the work of the dependencies. Let's break the process down with an example.
The fields won’t be displayed unless a particular setting is enabled or selected.
  1. 1.
    For example, there is a field for skin color setup. By default, the theme color are applied and there are no additional settings. But if you select the Custom Color option, the new fields (color picker) will be displayed. These fields depend on the Custom Color option.
Could not load image
1
'dependency' => array(
2
'key' => 'footer_custom_settings',
3
'value' => 'not_empty'
4
)
Copied!
The 'value' => 'not_empty' indicates that if the setting is enabled, the field will be displayed.
2. Another example of dependency usage. There are three option fields, two of them depend on the third one. When you select Hide Footer (enable the option) other two settings will be automatically disabled and hidden.
Could not load image
Could not load image
1
'dependency' => array(
2
'key' => '‘footer_show_hide',
3
'value' => 'empty'
4
)
Copied!
The 'value' => 'empty' indicates that if the setting is disabled (or not selected) the field won’t be displayed
3. There is also another way of dependency management when some of the fields depend on two options at once.
Could not load image
1
'dependency' => array(
2
array(
3
'key' => 'footer_custom_settings',
4
'value' => 'not_empty'
5
),
6
array(
7
'key' => 'footer_show_hide',
8
'value' => 'empty'
9
)
10
),
11
'dependencies' => '&&'
Copied!
Pay attention to the “dependencies” option. It shows that a particular field depends on multiple options.
The value of '&&' means “and” here, and the option depends on fields 1 and 2.
You can also use “||” - to indicate “or” - for example, if the field depends on several options, and if only one of them is selected (enabled).
NOTE: if dependency field located in another section, you have to add section name parameter to dependency array:
1
'dependency' => array(
2
array(
3
'key' => 'footer_custom_settings',
4
'value' => 'not_empty',
5
'section' => 'my_section_name'
6
),
7
),
Copied!
🚩
🚩
🚩
Sometimes you need to show that the setting is not available in certain cases, just add
1
'dependency_mode' => 'disabled',
Copied!
and setting will be disabled.
For example, we need to show, that WooCommerce cart is disabled for Header style 6:
Last modified 9mo ago
Copy link