JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
changed metaform's checkbox to use 0/1 in php and mysql
authorJason <jason@parth.(none)>
Mon, 15 Sep 2008 21:44:54 +0000 (17:44 -0400)
committerJason <jason@parth.(none)>
Mon, 15 Sep 2008 21:44:54 +0000 (17:44 -0400)
encode.php
format.php
metaform.php
metaform/template.email.txt

index d37d1fa..f93387b 100644 (file)
@@ -106,6 +106,18 @@ function enc_checked($str) {
        }
 }
 
+# checkboxe values are stored in the db and handled in php as 0 or 1. When you
+# want it displayed as "Yes" or "No" use this:
+# Example: (displaying values from a form submission)  Over 60?: ~over_60.yesno~
+function enc_yesno($str) {
+       if($str && $str !== 'No' && $str !== 'False' && $str !== 'false') {
+               return 'Yes';
+       } else {
+               return 'No';
+       }
+}
+
+
 # add a tab at the begining of each non-empty line
 function enc_tab($str) {
        $lines = explode("\n", $str);
index f63dfba..de45928 100644 (file)
@@ -124,8 +124,16 @@ function format_unix($str) {
        return unix_newlines($str);
 }
 
+function format_bool($str) {
+       if($str && $str !== 'No' && $str !== 'False' && $str !== 'false') {
+               return 'Yes';
+       } else {
+               return 'No';
+       }
+}
+
 function format_yesno($str) {
-       if($str && $str != 'No') {
+       if($str && $str !== 'No' && $str !== 'False' && $str !== 'false') {
                return 'Yes';
        } else {
                return 'No';
index ab4b305..f7a5740 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)'),
@@ -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');
                }
index 0a3f287..c61be5f 100644 (file)
@@ -1,5 +1,6 @@
 ~form_name~ form submitted with the following:
 <!--~fields start~--><!--~normal start~-->
-~caption~: ~~~name~~~<!--~end~--><!--~multi_line start~-->
+~caption~: ~~~name~~~<!--~end~--><!--~checkbox start~-->
+~caption~: ~~~name~.yesno~~<!--~end~--><!--~multi_line start~-->
 ~caption~:
 ~~~name~.tab~~<!--~end~--><!--~end~-->