From f388442b260e41d1dbe05dd6eeb5f30fb8800010 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Wed, 15 Nov 2006 07:36:00 +0000 Subject: [PATCH] added removeOption method to allow removing options from a select drop down --- lib/form/select.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/form/select.php b/lib/form/select.php index 28ead18a82..b86d295bd7 100644 --- a/lib/form/select.php +++ b/lib/form/select.php @@ -42,5 +42,26 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{ function getHelpButton(){ return $this->_helpbutton; } + /** + * Removes an OPTION from the SELECT + * + * @param string $value Value for the OPTION to remove + * @since 1.0 + * @access public + * @return void + */ + function removeOption($value) + { + $key=array_search($value, $this->_values); + if ($key!==FALSE || $key!==null) { + unset($this->_values[$key]); + } + foreach ($this->_options as $key=>$option){ + if ($option['attr']['value']==$value){ + unset($this->_options[$key]); + return; + } + } + } // end func removeOption } ?> \ No newline at end of file -- 2.39.5