function rules_ui_element_decimal_validate

FAPI validation of a decimal element.

Improved version of the private function _element_validate_number().

1 string reference to 'rules_ui_element_decimal_validate'
RulesDataUIDecimal::inputForm in ui/ui.data.inc
Implements RulesDataDirectInputFormInterface::inputForm().

File

ui/ui.forms.inc, line 715

Code

function rules_ui_element_decimal_validate($element, &$form_state) {
    // Substitute the decimal separator ",".
    $value = strtr($element['#value'], ',', '.');
    if ($value != '' && !is_numeric($value)) {
        form_error($element, t('%name must be a number.', array(
            '%name' => $element['#title'],
        )));
    }
    elseif ($value != $element['#value']) {
        form_set_value($element, $value, $form_state);
    }
}