Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-30940 form: Mutiple select work correctly without any selection

  • Loading branch information...
commit 8154dd835032f3a2ffd989220c319cb0cd68c6b9 1 parent 931eff3
@FMCorz FMCorz authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/form/select.php
View
14 lib/form/select.php
@@ -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.