JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
metaform: fixed SQL for decimal and other weird numeric types
[wfpl.git] / metaform.php
index ab4b305..e9c73ec 100644 (file)
@@ -50,7 +50,7 @@ $GLOBALS['types'] = array(
        'pulldown' =>   array('pulldown',    'options',    'varchar(100)'),
        'radio' =>      array('radio',       'oneline',    'varchar(200)'),
        'leftcheck' =>  array('leftcheck',   'yesno',      'varchar(3)'),
-       'checkbox' =>   array('checkbox',    'yesno',      'varchar(3)'),
+       'checkbox' =>   array('checkbox',    'bool',       'int(1)'),
        'yesno' =>      array('checkbox',    'yesno',      'varchar(3)'),
        'delete' =>     array('checkbox',    'yesno',      'n/a'),
        'image' =>      array('image',       'oneline',    'varchar(200)'),
@@ -170,7 +170,7 @@ function make_sql() {
                if($sql != 'n/a') {
                        $tem->set('name', $name);
                        $tem->set('type', $sql);
-                       if($sql == 'int') {
+                       if(substr($sql, 0, 3) == 'int' || substr($sql, 0, 7) == 'decimal') {
                                $tem->set('default', '0');
                        } elseif($format == 'yesno') {
                                $tem->set('default', '"No"');
@@ -370,6 +370,8 @@ function make_email() {
                $tem->set('caption', $name); # fixme
                if($type == 'textarea') {
                        $tem->show('multi_line');
+               } elseif($type == 'checkbox') {
+                       $tem->show('checkbox');
                } else {
                        $tem->show('normal');
                }