Active
Project:
Content Construction Kit (CCK)
Version:
6.x-2.9
Component:
number.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2011 at 13:05 UTC
Updated:
13 Sep 2011 at 07:07 UTC
I have a content type with an integer field with a text field widget. I set minimum value 10000 and maximum value 99999 (like a ZIP code).
When I create new content and enter the value "12-" in that field, there's no validation error. I expected it to cast the value to integer and finding that 12 < 10000, but it didn't.
The problem is in the function number_field() in number.module:
if (is_numeric($field['min']) && $item['value'] < $field['min']) {
form_set_error( ... );
}
if (is_numeric($field['max']) && $item['value'] > $field['max']) {
form_set_error( ... );
}
$item['value'] and $field['min'] are strings, and PHP actually returns FALSE for ("12-" < "10000"), so comparing strings is wrong. Instead both values should be casted to integer or decimal and then compared.
Comments
Comment #1
Roze-1 commentedSubscribing