MDL-56864 forms: allow to remove last tag with forced standard tags
authorMarina Glancy <marina@moodle.com>
Tue, 21 Nov 2017 07:19:44 +0000 (15:19 +0800)
committerMarina Glancy <marina@moodle.com>
Tue, 21 Nov 2017 07:29:03 +0000 (15:29 +0800)
lib/form/tags.php

index 390c723..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);