diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-09-06 23:44:39 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-09-06 23:44:39 -0400 |
commit | 6f6cd6b1ede633a7db06b5e40919eb1cc4279713 (patch) | |
tree | d4aec88459559db6a7510895399b180bf982d337 /src/views/Template.class.php | |
parent | 710e269b328ec055f90d4521ef8806fa1b4ea83a (diff) |
Differentiate between when we want checkboxes to be booleans, or bit arrays.
For the booleans, we use a hidden input to send false back if they aren't selected.
* Template.class.php: rename inputBool() to inputBoolArray(), create new inputBool()
* index.html.php: use a hidden input to send false when an checkbox isn't selected.
* individual.html.php: add inputBool() function, use $t->inputBoolArray() in inputArray()
Diffstat (limited to 'src/views/Template.class.php')
-rw-r--r-- | src/views/Template.class.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/views/Template.class.php b/src/views/Template.class.php index b128ef3..ba51a2f 100644 --- a/src/views/Template.class.php +++ b/src/views/Template.class.php @@ -254,9 +254,35 @@ class Template { "\n".$this->tabs()."\t". $this->inputStr('password', $id.'_verify', $default,$lock)); } - public function inputBool($name, $value, $label, $default=FALSE, $lock=FALSE) { + public function inputBool($id, $label, $hint='', $default=FALSE, $lock=FALSE) { + $tag = ''; + if ($lock) $tag.= "readonly='readonly' "; + if ($default) $tag.= "checked='checked' "; + return $this->input($id, $label, $hint, + "<input type='hidden' name='$id' value='false' />". + "<input type='checkbox' id='$id' name='$id' value='true' $tag>"); + + $attrib = array('type'=>'checkbox', + 'id'=>$id, + 'name'=>$name.'[]', + 'value'=>$value); + if ($default) $attrib['checked']='checked'; + if ($lock ) $attrib['readonly']='readonly'; + + $str = $this->openTag('li'); + $str.= $this->tag('input', $attrib); + $str.= $this->tag('label', array('for'=>$id), $label); + $str.= $this->closeTag('li'); + + if ($this->ret) return $str; + echo $str; + + } + + public function inputBoolArray($name, $value, $label, $default=FALSE, $lock=FALSE) { + $id = $name.'_'.$value; $attrib = array('type'=>'checkbox', - 'id'=>$name.'_'.$value, + 'id'=>$id, 'name'=>$name.'[]', 'value'=>$value); if ($default) $attrib['checked']='checked'; |