Skip to content

Commit

Permalink
No longer use any javascript for advcheckbox, this fixes bug #6134
Browse files Browse the repository at this point in the history
Methods getPrivateName() and getOnclickJs() are deprecated (why were they public in the first place?)


git-svn-id: http://svn.php.net/repository/pear/packages/HTML_QuickForm/trunk@215112 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
sad-spirit committed Jun 20, 2006
1 parent 528dce1 commit dc20fcb
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions QuickForm/advcheckbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,12 +87,14 @@ function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text
// {{{ 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)
{
Expand All @@ -109,6 +112,8 @@ function getPrivateName($elementName)
*
* @access public
* @return string
*
* @deprecated Deprecated since 3.2.6, this element no longer uses any javascript
*/
function getOnclickJs($elementName)
{
Expand Down Expand Up @@ -140,6 +145,7 @@ function setValues($values)
} else {
$this->_values = $values;
}
$this->updateAttributes(array('value' => $this->_values[1]));
$this->setChecked($this->_currentValue == $this->_values[1]);
}

Expand Down Expand Up @@ -191,24 +197,12 @@ function toHtml()
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

Expand Down

0 comments on commit dc20fcb

Please sign in to comment.