public static function formRule($fields, $files, $self) {
$errors = [];
$fieldSelected = FALSE;
+ $actualThreshold = 0;
for ($count = 0; $count < self::RULES_COUNT; $count++) {
if (!empty($fields["where_$count"]) || (isset($self->_defaults['is_reserved']) && !empty($self->_defaults["where_$count"]))) {
$fieldSelected = TRUE;
break;
}
+ if (!empty($self->_defaults["weight_$count"])) {
+ $actualThreshold += $self->_defaults["weight_$count"];
+ }
}
if (empty($fields['threshold'])) {
// CRM-20607 - Don't validate the threshold of hard-coded rules
$errors['threshold'] = ts('Threshold weight cannot be empty or zero.');
}
}
+ else {
+ if ($actualThreshold < $fields['threshold']) {
+ $errors['threshold'] = ts('Total weight must be greater than or equal to the Weight Threshold.');
+ }
+ }
if (!$fieldSelected) {
$errors['_qf_default'] = ts('Please select at least one field.');