# Using the
Fields may be linked/required/folded according to a/multiple parent value(s). This is accomplished by appending a
required argument to the field. Required can be very powerful, but due to the complexity requires
some careful consideration when using.
Table of Contents
# Example Config
To link a field's visibility to the value of another:
array( 'required' => array( 'LINKED_FIELD_ID', 'OPERATION', 'VALUE' ) )
| ||Field ID that will affect the visibility of this field|
| ||Comparison operation to perform|
| ||Value is the value to compare against for visibility|
You can also link a field with multiple "parent" required values. If all of these conditions are not met, this field will not be visible and the field CSS will not be used. An example is as follows:
array( 'required' => array( array( 'LINKED_FIELD_ID_1', 'OPERATION_1', 'VALUE_1' ), array( 'LINKED_FIELD_ID_2', 'OPERATION_2', 'VALUE_2' ) ) )
If you are checking the same key againt a different value then you have to do it as follows:
array( 'required' => array( array( 'LINKED_FIELD_ID_1', 'OPERATION_1', array( 'VALUE_1', 'VALUE_2' ) ) ) )
# Operations Available
To attempt to support the various possibilities, a number of options have been coded. These operations have been found to support the majority of needs.
If any parent is hidden or doesn't match the value, all children are hidden and all CSS output from those children is hidden as well.
# CSS Output
CSS output to both the head and compiler is removed from each field if the required value(s) is/are not met. You can,
however, override this on a per-field basis by setting
'force_output' => true for each field you want CSS to still be
output with. This way you can nest a field under another, and still have it output to the dynamic CSS.
The CSS output will always be visible if items are within a
section field unless that specific field has the required value set to the required parent as well.
← Permissions Validate →