cvs: pear /HTML_QuickForm/QuickForm radio.php
| From: | Bertrand Mansion | Date: | Wed, 20 Nov 2002 10:25:45 +0000 |
| Subject: | cvs: pear /HTML_QuickForm/QuickForm radio.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7503@lists.php.net to get a copy of this message | ||
mansion Wed Nov 20 05:25:45 2002 EDT
Modified files:
/pear/HTML_QuickForm/QuickForm radio.php
Log:
Fix the way values are set in Radio.
Index: pear/HTML_QuickForm/QuickForm/radio.php
diff -u pear/HTML_QuickForm/QuickForm/radio.php:1.7 pear/HTML_QuickForm/QuickForm/radio.php:1.8
--- pear/HTML_QuickForm/QuickForm/radio.php:1.7 Fri Sep 27 07:49:46 2002
+++ pear/HTML_QuickForm/QuickForm/radio.php Wed Nov 20 05:25:45 2002
@@ -17,9 +17,9 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: radio.php,v 1.7 2002/09/27 11:49:46 mansion Exp $
+// $Id: radio.php,v 1.8 2002/11/20 10:25:45 mansion Exp $
-require_once("HTML/QuickForm/input.php");
+require_once('HTML/QuickForm/input.php');
/**
* HTML class for a radio type element
@@ -40,7 +40,7 @@
* @since 1.1
* @access private
*/
- var $_text = "";
+ var $_text = '';
// }}}
// {{{ constructor
@@ -72,10 +72,6 @@
$this->_persistantFreeze = true;
$this->setType('radio');
$this->_text = $text;
- $vars = array_merge($_GET, $_POST);
- if (isset($vars[$this->getName()]) && $vars[$this->getName()] ==
$this->getValue()) {
- $this->setChecked(true);
- }
} //end constructor
// }}}
@@ -128,7 +124,7 @@
*/
function toHtml()
{
- return HTML_QuickForm_input::toHtml() . "" . $this->_text;
+ return HTML_QuickForm_input::toHtml() . '' . $this->_text;
} //end func toHtml
// }}}
@@ -144,12 +140,13 @@
*/
function getFrozenHtml()
{
+ $html = '';
if ($this->getChecked()) {
- $html = "<tt>(x)</tt>";
+ $html .= '<tt>(x)</tt>';
} else {
- $html = "<tt>( )</tt>";
+ $html .= '<tt>( )</tt>';
}
- return $html . "";
+ return $html;
} //end func getFrozenHtml
// }}}
@@ -166,7 +163,7 @@
*/
function setText($text)
{
- $this->_text = $text;
+ $this->_text = $text;
} //end func setText
// }}}
@@ -206,10 +203,16 @@
case 'addElement':
case 'createElement':
$this->$className($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]);
+ // need to set the submit value in case setDefault never gets called
+ $elementName = $this->getName();
+ if (isset($caller->_submitValues[$elementName]) &&
$caller->_submitValues[$elementName] == $this->getValue()) {
+ $this->setChecked(true);
+ }
break;
case 'setDefault':
- $vars = array_merge($_GET, $_POST);
- if (!isset($vars[$this->getName()])) {
+ // In form display, default value is always overidden by submitted value
+ $elementName = $this->getName();
+ if (!isset($caller->_submitValues[$elementName])) {
if ($arg == $this->getValue()) {
$this->setChecked(true);
} else {
@@ -218,6 +221,8 @@
}
break;
case 'setConstant':
+ // In form display, constant value overides submitted value
+ // but submitted value is kept in _submitValues array
if ($arg == $this->getValue()) {
$this->setChecked(true);
} else {
@@ -237,4 +242,4 @@
// }}}
} //end class HTML_QuickForm_radio
-?>
+?>
\ No newline at end of file