Hello,

Thank you for this module. I need to test if the number entered is an integer. I've look at your code and I've tried to replace

// Validate function for attributes that must be numeric.
function uc_attribute_numeric_validate($element, &$form_state) {
  if (!empty($element['#value']) && !is_numeric($element['#value'])) {
    form_error($element, t('@title must be numeric.', array('@title' => $element['#title'])));
  }
}

with

// Validate function for attributes that must be numeric.
function uc_attribute_numeric_validate($element, &$form_state) {
  if (!empty($element['#value']) && !is_int($element['#value'])) {
    form_error($element, t('@title must be numeric.', array('@title' => $element['#title'])));
  }
}

but in the php doc it says "To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric(). "

Where can I convert the value in integer if the var pass the function uc_attribute_numeric_validate() ?

Thanks in advance.

Comments

selinav’s picture

Could you give me a tip, please?