Active
Project:
Ubercart Attribute Length
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2011 at 12:38 UTC
Updated:
3 Oct 2011 at 09:31 UTC
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
Comment #1
selinav commentedCould you give me a tip, please?