function conditional_fields_evaluate_grouping in Conditional Fields 7.3
Evaluates an array with 'AND', 'OR' and 'XOR' groupings, each containing a list of boolean values.
2 calls to conditional_fields_evaluate_grouping()
- conditional_fields_entity_view_alter in ./
conditional_fields.module - Implements hook_entity_view_alter().
- conditional_fields_evaluate_dependencies in ./
conditional_fields.module - Evaluate a set of dependencies for a dependent field.
File
- ./
conditional_fields.module, line 982 - Define dependencies between fields based on their states and values.
Code
function conditional_fields_evaluate_grouping($groups) {
$or = $and = $xor = TRUE;
if (!empty($groups['OR'])) {
$or = in_array(TRUE, $groups['OR']);
}
if (!empty($groups['AND'])) {
$and = !in_array(FALSE, $groups['AND']);
}
if (!empty($groups['XOR'])) {
$xor = array_sum($groups['XOR']) == 1;
}
return $or && $and && $xor;
}