}
}
+# 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);
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';
'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)'),
$tem->set('caption', $name); # fixme
if($type == 'textarea') {
$tem->show('multi_line');
+ } elseif($type == 'checkbox') {
+ $tem->show('checkbox');
} else {
$tem->show('normal');
}
~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~-->