[QuickForms] replacing options in select?

From: Date: Tue, 18 Mar 2003 14:43:37 +0000
Subject: [QuickForms] replacing options in select?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4289@lists.php.net to get a copy of this message
Hi, I want to reduce the base set of options in a select widget. Is there any API to do this, or a clever combination of get_element on the form or something? To get round my problem I have overloaded loadArray on select.php as follows: function loadArray($arr, $values=null) { if (!is_array($arr)) { return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array'); } if (isset($values)) { $this->setSelected($values); } $this->_options = array(); // <-- Added line to zap array foreach ($arr as $key => $val) { // Warning: new API since release 2.3 $this->addOption($val, $key); } return true; } // end func loadArray Does this make sense, or is there a better way? Thanks, geoff -- Geoff Hopson Objectology Ltd. http://www.objectology.co.uk/

« previous php.pear.general (#4289) next »