2

When trying to update the settings of an integer field in the user fields, there is an error on saving and the logs show the following error:

PHP Fatal error: Call to undefined function element_validate_number() in /var/www/vhosts/**/includes/form.inc on line 1361

1 Answer 1

2

element_validate_number() was added in Drupal 7.6 (or 7.8, I can't quite remember) so it may be that you have an older version of core that doesn't contain that function.

If you can't upgrade your version of core, try adding this into a module file, it should save you the headache:

if (!function_exists('element_validate_number')) {
  function element_validate_number($element, &$form_state) {
    $value = $element['#value'];
    if ($value != '' && !is_numeric($value)) {
      form_error($element, t('%name must be a number.', array('%name' => $element['#title'])));
    }
  }
}

In case you're interested element_validate_number() is the replacement for the deprecated _element_validate_number().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.