Index: /library/Zend/View/Helper/FormCheckbox.php
===================================================================
--- /library/Zend/View/Helper/FormCheckbox.php (revision 7102)
+++ /library/Zend/View/Helper/FormCheckbox.php (working copy)
@@ -50,10 +50,11 @@
* @param mixed $options If a scalar (single value), the value of the
* checkbox when checked; if an array, element 0 is the value when
* checked, and element 1 is the value when not-checked.
+ * @param boolean $genHidden Whether or not to generate hidden fields.
* @return string The element XHTML.
*/
public function formCheckbox($name, $value = null, $attribs = null,
- $options = array(1,0))
+ $options = array(1,0), $genHidden = true)
{
$info = $this->_getInfo($name, $value, $attribs, $options);
extract($info); // name, id, value, attribs, options, listsep, disable
@@ -72,15 +73,20 @@
}
}
+ $xhtml = '';
+
// build the element
if ($disable) {
// disabled.
+ if ($genHidden) {
+ $xhtml .= $this->_hidden($name, $options[$value != $options[0]]);
+ }
if ($value == $options[0]) {
// checked
- $xhtml = $this->_hidden($name, $options[0]) . '[x]';
+ $xhtml .= '[x]';
} else {
// not checked
- $xhtml = $this->_hidden($name, $options[1]) . '[ ]';
+ $xhtml .= '[ ]';
}
} else {
// enabled. add the hidden "unchecked" option first, then
@@ -86,11 +92,13 @@
// enabled. add the hidden "unchecked" option first, then
// the the checkbox itself) next. this way, if not-checked,
// the "unchecked" option is returned to the server instead.
- $xhtml = $this->_hidden($name, $options[1])
- . '_hidden($name, $options[1]);
+ }
+ $xhtml .= '