From e62e473d44494808e584383af24f8d219f8fc745 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 19 Apr 2013 11:04:34 +0800 Subject: [PATCH] MDL-30940 form: Mutiple select work correctly without any selection --- lib/form/select.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/form/select.php b/lib/form/select.php index 6d17686b146..8b0beba3920 100644 --- a/lib/form/select.php +++ b/lib/form/select.php @@ -71,13 +71,19 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{ * @return string */ function toHtml(){ + $html = ''; + if ($this->getMultiple()) { + // Adding an hidden field forces the browser to send an empty data even though the user did not + // select any element. This value will be cleaned up in self::exportValue() as it will not be part + // of the select options. + $html .= ''; + } if ($this->_hiddenLabel){ $this->_generateId(); - return ''.parent::toHtml(); - } else { - return parent::toHtml(); + $html .= ''; } + $html .= parent::toHtml(); + return $html; } /**