cvs: pear /HTML_QuickForm/QuickForm advcheckbox.php
| From: | Alexey Borzov | Date: | Tue, 20 Jun 2006 16:33:06 +0000 |
| Subject: | cvs: pear /HTML_QuickForm/QuickForm advcheckbox.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-40842@lists.php.net to get a copy of this message | ||
avb Tue Jun 20 16:33:06 2006 UTC
Modified files:
/pear/HTML_QuickForm/QuickForm advcheckbox.php
Log:
No longer use any javascript for advcheckbox, this fixes bug #6134
Methods getPrivateName() and getOnclickJs() are deprecated (why were they public in the first
place?)
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm/QuickForm/advcheckbox.php?r1=1.15&r2=1.16&diff_format=u
Index: pear/HTML_QuickForm/QuickForm/advcheckbox.php
diff -u pear/HTML_QuickForm/QuickForm/advcheckbox.php:1.15
pear/HTML_QuickForm/QuickForm/advcheckbox.php:1.16
--- pear/HTML_QuickForm/QuickForm/advcheckbox.php:1.15 Fri Jun 24 17:58:29 2005
+++ pear/HTML_QuickForm/QuickForm/advcheckbox.php Tue Jun 20 16:33:06 2006
@@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: advcheckbox.php,v 1.15 2005/06/24 17:58:29 avb Exp $
+// $Id: advcheckbox.php,v 1.16 2006/06/20 16:33:06 avb Exp $
require_once('HTML/QuickForm/checkbox.php');
@@ -31,9 +31,10 @@
* furthermore the checkbox variable doesn't even exist if
* the checkbox was submitted unchecked.
*
- * It works by creating a hidden field with the passed-in name
- * and creating the checkbox with no name, but with a javascript
- * onclick which sets the value of the hidden field.
+ * It works by prepending a hidden field with the same name and
+ * another "unchecked" value to the checbox. If the checkbox is
+ * checked, PHP overwrites the value of the hidden field with
+ * its value.
*
* @author Jason Rust <jrust@php.net>
* @since 2.0
@@ -86,12 +87,14 @@
// {{{ getPrivateName()
/**
- * Gets the pribate name for the element
+ * Gets the private name for the element
*
* @param string $elementName The element name to make private
*
* @access public
* @return string
+ *
+ * @deprecated Deprecated since 3.2.6, both generated elements have the same name
*/
function getPrivateName($elementName)
{
@@ -109,6 +112,8 @@
*
* @access public
* @return string
+ *
+ * @deprecated Deprecated since 3.2.6, this element no longer uses any javascript
*/
function getOnclickJs($elementName)
{
@@ -140,6 +145,7 @@
} else {
$this->_values = $values;
}
+ $this->updateAttributes(array('value' => $this->_values[1]));
$this->setChecked($this->_currentValue == $this->_values[1]);
}
@@ -191,24 +197,12 @@
if ($this->_flagFrozen) {
return parent::toHtml();
} else {
- $oldName = $this->getName();
- $oldJs = $this->getAttribute('onclick');
- $this->updateAttributes(array(
- 'name' => $this->getPrivateName($oldName),
- 'onclick' => $this->getOnclickJs($oldName) . ' ' . $oldJs
- ));
- $html = parent::toHtml() . '<input' .
- $this->_getAttrString(array(
+ return '<input' . $this->_getAttrString(array(
'type' => 'hidden',
- 'name' => $oldName,
- 'value' => $this->getValue()
- )) . ' />';
- // revert the name and JS, in case this method will be called once more
- $this->updateAttributes(array(
- 'name' => $oldName,
- 'onclick' => $oldJs
- ));
- return $html;
+ 'name' => $this->getName(),
+ 'value' => $this->_values[0]
+ )) . ' />' . parent::toHtml();
+
}
} //end func toHtml