cvs: pear /HTML_QuickForm/QuickForm hierselect.php

From: Date: Sun, 07 Sep 2003 13:50:58 +0000
Subject: cvs: pear /HTML_QuickForm/QuickForm hierselect.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-12527@lists.php.net to get a copy of this message
mansion Sun Sep 7 09:50:58 2003 EDT Modified files: /pear/HTML_QuickForm/QuickForm hierselect.php Log: Fix Bug #25193: setDefaults for hierselect does not have to preceed addElement anymore. Reported by Keith, midnighthax.com Index: pear/HTML_QuickForm/QuickForm/hierselect.php diff -u pear/HTML_QuickForm/QuickForm/hierselect.php:1.2 pear/HTML_QuickForm/QuickForm/hierselect.php:1.3 --- pear/HTML_QuickForm/QuickForm/hierselect.php:1.2 Sat Jul 5 12:05:57 2003 +++ pear/HTML_QuickForm/QuickForm/hierselect.php Sun Sep 7 09:50:57 2003 @@ -16,7 +16,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: hierselect.php,v 1.2 2003/07/05 16:05:57 mansion Exp $ +// $Id: hierselect.php,v 1.3 2003/09/07 13:50:57 mansion Exp $ require_once('HTML/QuickForm/group.php'); require_once('HTML/QuickForm/select.php'); @@ -172,10 +172,15 @@ function setValue($value) { parent::setValue($value); + // Reload the options in the second selects if (sizeof($this->_secOptions) > 0) { if (is_array($value)) { - $curKey = isset($this->_secOptions[$value[0][0]]) ? $value[0][0] : key($this->_secOptions); + if (isset($this->_secOptions[$value[0]][$value[1]])) { + $curKey = $value[0]; + } else { + $curKey = key($this->_secOptions); + } } else { $curKey = key($this->_secOptions); } @@ -249,6 +254,20 @@ { $renderer->renderElement($this, $required, $error); } // end func accept + + // }}} + // {{{ onQuickFormEvent() + + function onQuickFormEvent($event, $arg, &$caller) + { + if ('updateValue' == $event) { + // we need to call setValue() so that the secondary option + // matches the main option + return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller); + } else { + return parent::onQuickFormEvent($event, $arg, $caller); + } + } // end func onQuickFormEvent // }}} } // end class HTML_QuickForm_hierselect

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