protected static function ConditionalFieldsFormHelper::evaluateGrouping in Conditional Fields 8
Same name and namespace in other branches
- 4.x src/ConditionalFieldsFormHelper.php \Drupal\conditional_fields\ConditionalFieldsFormHelper::evaluateGrouping()
Evaluates an array with 'AND', 'OR' and 'XOR' groupings.
Each containing a list of boolean values.
1 call to ConditionalFieldsFormHelper::evaluateGrouping()
- ConditionalFieldsFormHelper::evaluateDependencies in src/
ConditionalFieldsFormHelper.php - Evaluate a set of dependencies for a dependent field.
File
- src/
ConditionalFieldsFormHelper.php, line 465
Class
- ConditionalFieldsFormHelper
- Helper to interact with forms.
Namespace
Drupal\conditional_fieldsCode
protected static function evaluateGrouping($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;
}