cvs: pear /HTML_QuickForm/QuickForm checkbox.php

From: Date: Tue, 29 Oct 2002 16:29:28 +0000
Subject: cvs: pear /HTML_QuickForm/QuickForm checkbox.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7235@lists.php.net to get a copy of this message
mansion Tue Oct 29 11:29:28 2002 EDT Modified files: /pear/HTML_QuickForm/QuickForm checkbox.php Log: With changes in element.php about submitted values, value was not been set correctly. Fixed. Index: pear/HTML_QuickForm/QuickForm/checkbox.php diff -u pear/HTML_QuickForm/QuickForm/checkbox.php:1.4 pear/HTML_QuickForm/QuickForm/checkbox.php:1.5 --- pear/HTML_QuickForm/QuickForm/checkbox.php:1.4 Tue Jun 4 20:01:47 2002 +++ pear/HTML_QuickForm/QuickForm/checkbox.php Tue Oct 29 11:29:27 2002 @@ -17,7 +17,7 @@ // | Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: checkbox.php,v 1.4 2002/06/05 00:01:47 jrust Exp $ +// $Id: checkbox.php,v 1.5 2002/10/29 16:29:27 mansion Exp $ require_once("HTML/QuickForm/input.php"); @@ -39,7 +39,7 @@ * @since 1.1 * @access private */ - var $_text = ""; + var $_text = ''; // }}} // {{{ constructor @@ -48,7 +48,8 @@ * Class constructor * * @param string $elementName (optional)Input field name attribute - * @param string $value (optional)Input field value + * @param string $elementLabel (optional)Input field value + * @param string $text (optional)Checkbox display text * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 @@ -56,7 +57,7 @@ * @return void * @throws */ - function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text=null, $attributes=null) + function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) { HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; @@ -227,10 +228,18 @@ case 'addElement': case 'createElement': $this->$className($arg[0], $arg[1], $arg[2], $arg[3]); + // need to set the submit value in case setDefault never gets called + $elementName = $this->getName(); + if (count($caller->_submitValues) > 0) { + $this->setChecked(isset($caller->_submitValues[$elementName])); + } break; case 'setDefault': - $vars = $caller->getSubmitValues(); - if (count($vars) == 0) { + // In form display, default value is always overidden by submitted value + $elementName = $this->getName(); + if (count($caller->_submitValues) > 0) { + $this->setChecked(isset($caller->_submitValues[$elementName])); + } else { $this->setChecked($arg); } break; @@ -242,9 +251,9 @@ break; } return true; - } // end func onQuickFormLoad + } // end func onQuickFormEvent // }}} } //end class HTML_QuickForm_checkbox -?> +?> \ No newline at end of file

« previous php.pear.cvs (#7235) next »