--- number.module	2007-01-25 21:16:01.000000000 +0100
+++ number.module.decimal_1	2007-01-25 22:43:37.000000000 +0100
@@ -12,6 +12,7 @@
 function number_field_info() {
   return array(
     'number_integer' => array('label' => 'Integer'),
+    'number_float'   => array('label' => 'Float'),
     'number_decimal' => array('label' => 'Decimal'),
   );
 }
@@ -52,6 +53,24 @@ function number_field_settings($op, $fie
         '#default_value' => isset($field['suffix']) ? $field['suffix'] : '',
         '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds). '),
       );
+      $form['advanced_datatype_settings'] = array(
+        '#type' => 'fieldset',
+        '#title' => 'Advanced datatype settings',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+      );
+      $form['advanced_datatype_settings']['db_length'] = array(
+        '#type' => 'textfield',
+        '#title' => 'Length',
+        '#default_value' => isset($field['db_length']) ? $field['db_length'] : '',
+        '#description' => 'Define the length "M,D" of the Numberic type. Depends on the selected number type [Integer(M), Float(M,D), Decimal(M,D)]. E.g. if you want to setup a monetary field, "10,2" is a good choice. This would allow you monetary values ranging from -99.999.999,99€ to 99.999.999,99€. See your database documentation for further information.',
+      );
+      $form['advanced_datatype_settings']['db_unsigned'] = array(
+        '#type' => 'checkbox',
+        '#title' => 'Unsigned',
+        '#default_value' => isset($field['db_unsigned']) ? $field['db_unsigned'] : '',
+        '#description' => 'If selected, disallows negative values',
+      );
       $form['allowed_values'] = array(
         '#type' => 'textarea',
         '#title' => t('Allowed values list'),
@@ -77,25 +96,58 @@ function number_field_settings($op, $fie
 
     case 'validate':
       if ($field['min'] && !is_numeric($field['min'])) {
-        form_set_error('rows', t('"Minimum" must be a number.'));
+        form_set_error('min', t('"Minimum" must be a number.'));
       }
       if ($field['max'] && !is_numeric($field['max'])) {
-        form_set_error('rows', t('"Maximum" must be a number.'));
+        form_set_error('max', t('"Maximum" must be a number.'));
+      }
+      // validate the db_length field
+      if ($field['db_length']) {
+        $length = explode(',', $field['db_length'], 2);
+        if ( ($length[0] && !is_numeric($length[0])) || ($length[1] && !is_numeric($length[1])) ) { 
+          form_set_error('db_length', t('"Length" in "Advanced datatype settings" must be of the format "M,D", wheras M and D are numeric.'));
+        }
       }
       break;
 
     case 'save':
-      return array('prefix', 'suffix', 'append_position', 'min', 'max', 'allowed_values', 'allowed_values_php');
+      return array('prefix', 'suffix', 'append_position', 'db_length', 'db_unsigned', 'min', 'max', 'allowed_values', 'allowed_values_php');
 
     case 'database columns':
       if ($field['type'] == 'number_integer') {
         return array(
-          'value' => array('type' => 'int', 'not null' => FALSE, 'default' => NULL, 'sortable' => TRUE),
+          'value' => array(
+            'type'     => 'int',
+//             'length'   => $field['db_length'],
+//             'unsigned' => $field['db_unsigned'],
+            'not null' => FALSE,
+            'default'  => NULL,
+            'sortable' => TRUE
+          ),
+        );
+      }
+      if ($field['type'] == 'number_float') {
+        return array(
+          'value' => array(
+            'type'     => 'float',
+//             'length'   => $field['db_length'],
+//             'unsigned' => $field['db_unsigned'],
+            'not null' => FALSE,
+            'default'  => NULL,
+            'sortable' => TRUE
+          ),
         );
       }
       if ($field['type'] == 'number_decimal') {
         return array(
-          'value' => array('type' => 'float', 'not null' => FALSE, 'default' => NULL, 'sortable' => TRUE),
+          'value' => array(
+            'type'     => 'decimal',
+//             'length'   => $field['db_length'],
+//             'unsigned' => $field['db_unsigned'],
+            'not null' => FALSE,
+            'default'  => NULL,
+            'sortable' => TRUE
+          ),
         );
       }
 
@@ -143,6 +195,9 @@ function number_field($op, &$node, $fiel
             if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
               form_set_error($error_field, t('Illegal value for %name.', array('%name' => t($field['widget']['label']))));
             }
+            if ($field['db_unsigned'] && $item['value'] < 0) {
+              form_set_error($error_field, t('Illegal value for %name. No negative values allowed.', array('%name' => t($field['widget']['label']))));
+            }
           }
         }
       }
@@ -156,17 +211,17 @@ function number_field($op, &$node, $fiel
 function number_field_formatter_info() {
 
   return array(
-    'default' => array('label' => '9999',             'field types' => array('number_integer', 'number_decimal')),
-    'us_0'    => array('label' => '9,999',            'field types' => array('number_integer', 'number_decimal')),
-    'us_1'    => array('label' => '9,999.9',          'field types' => array('number_decimal')),
-    'us_2'    => array('label' => '9,999.99',         'field types' => array('number_decimal')),
-    'be_0'    => array('label' => '9.999',            'field types' => array('number_integer', 'number_decimal')),
-    'be_1'    => array('label' => '9.999, 9',         'field types' => array('number_decimal')),
-    'be_2'    => array('label' => '9.999, 99',        'field types' => array('number_decimal')),
-    'fr_0'    => array('label' => '9 999',            'field types' => array('number_integer', 'number_decimal')),
-    'fr_1'    => array('label' => '9 999, 9',         'field types' => array('number_decimal')),
-    'fr_2'    => array('label' => '9 999, 99',        'field types' => array('number_decimal')),
-    'unformatted' => array('label' => 'unformatted',  'field types' => array('number_integer', 'number_decimal')),
+    'default'     => array('label' => '9999',             'field types' => array('number_integer',  'number_float', 'number_decimal')),
+    'us_0'        => array('label' => '9,999',            'field types' => array('number_integer',  'number_float', 'number_decimal')),
+    'us_1'        => array('label' => '9,999.9',          'field types' => array(                   'number_float', 'number_decimal')),
+    'us_2'        => array('label' => '9,999.99',         'field types' => array(                   'number_float', 'number_decimal')),
+    'be_0'        => array('label' => '9.999',            'field types' => array('number_integer',  'number_float', 'number_decimal')),
+    'be_1'        => array('label' => '9.999, 9',         'field types' => array(                   'number_float', 'number_decimal')),
+    'be_2'        => array('label' => '9.999, 99',        'field types' => array(                   'number_float', 'number_decimal')),
+    'fr_0'        => array('label' => '9 999',            'field types' => array('number_integer',  'number_float', 'number_decimal')),
+    'fr_1'        => array('label' => '9 999, 9',         'field types' => array(                   'number_float', 'number_decimal')),
+    'fr_2'        => array('label' => '9 999, 99',        'field types' => array(                   'number_float', 'number_decimal')),
+    'unformatted' => array('label' => 'unformatted',      'field types' => array('number_integer',  'number_float', 'number_decimal')),
   );
 }
 
@@ -252,7 +307,7 @@ function number_widget_info() {
   return array(
     'number' => array(
       'label' => 'Text Field',
-      'field types' => array('number_integer', 'number_decimal'),
+      'field types' => array('number_integer', 'number_float', 'number_decimal'),
     ),
   );
 }
