diff --git a/lib/form/select.php b/lib/form/select.php index 22c8752d1b7..7832f028636 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; } /**