Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-30940-24' of git://github.com/FMCorz/moodle into MO…

…ODLE_24_STABLE
  • Loading branch information...
commit 6f9d4498d2c0737ac70a383228f5813d1b447d9a 2 parents 8927b51 + 8154dd8
Damyon Wiese damyon authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/form/select.php
14 lib/form/select.php
View
@@ -71,13 +71,19 @@ function setHiddenLabel($hiddenLabel){
* @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 .= '<input type="hidden" name="'.$this->getName().'" value="_qf__force_multiselect_submission">';
+ }
if ($this->_hiddenLabel){
$this->_generateId();
- return '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
- $this->getLabel().'</label>'.parent::toHtml();
- } else {
- return parent::toHtml();
+ $html .= '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.$this->getLabel().'</label>';
}
+ $html .= parent::toHtml();
+ return $html;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.