Merge branch 'wip-MDL-56864-master' of git://github.com/marinaglancy/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 12 Dec 2017 05:36:32 +0000 (13:36 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 12 Dec 2017 05:36:32 +0000 (13:36 +0800)
lib/form/tags.php
theme/boost/templates/core_form/element-tags-inline.mustache
theme/boost/templates/core_form/element-tags.mustache

index b62eaf9..ef3719f 100644 (file)
@@ -244,7 +244,11 @@ class MoodleQuickForm_tags extends MoodleQuickForm_autocomplete {
      */
     public function exportValue(&$submitValues, $assoc = false) {
         if (!$this->is_tagging_enabled()) {
-            return $assoc ? array($this->getName() => array()) : array();
+            return $this->_prepareValue([], $assoc);
+        }
+        if ($this->_findValue($submitValues) === '_qf__force_multiselect_submission') {
+            // Nothing was selected.
+            return $this->_prepareValue([], $assoc);
         }
 
         return parent::exportValue($submitValues, $assoc);
@@ -257,6 +261,7 @@ class MoodleQuickForm_tags extends MoodleQuickForm_autocomplete {
             $url = new moodle_url('/tag/manage.php', array('tc' => $this->get_tag_collection()));
             $context['managestandardtagsurl'] = $url->out(false);
         }
+        $context['nameraw'] = $this->getName();
 
         return $context;
     }
index d4a79dc..5552bac 100644 (file)
@@ -1,6 +1,7 @@
 {{< core_form/element-template-inline }}
     {{$element}}
         {{^element.frozen}}
+        <input type="hidden" name="{{element.nameraw}}" value="_qf__force_multiselect_submission">
         <select class="custom-select {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
             id="{{element.id}}"
             {{#element.multiple}}multiple{{/element.multiple}}
index c0e910e..5f95675 100644 (file)
@@ -1,6 +1,7 @@
 {{< core_form/element-template }}
     {{$element}}
         {{^element.frozen}}
+        <input type="hidden" name="{{element.nameraw}}" value="_qf__force_multiselect_submission">
         <select class="custom-select {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
             id="{{element.id}}"
             {{#element.multiple}}multiple{{/element.multiple}}