Permalink
Browse files

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

…ODLE_23_STABLE
  • Loading branch information...
2 parents 018e8a9 + 50a40ae commit 70f7ea93271a092aff50503ad74666e5f008afbc @damyon damyon committed Apr 29, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 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;
}
/**

0 comments on commit 70f7ea9

Please sign in to comment.