From 0d226686ee14a74afe7dba744d000e9048a8d802 Mon Sep 17 00:00:00 2001
From: Mingsong Hu <mingsonghu@Mingsongs-MBP.gateway>
Date: Wed, 13 Nov 2019 12:19:04 +1100
Subject: [PATCH] Fix submit function bug that prevents a taxonomy from saving
 while taxononmy plugin is disabled

---
 src/Form/HmOverviewTerms.php | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/Form/HmOverviewTerms.php b/src/Form/HmOverviewTerms.php
index c861cd4..a229648 100644
--- a/src/Form/HmOverviewTerms.php
+++ b/src/Form/HmOverviewTerms.php
@@ -87,7 +87,22 @@ class HmOverviewTerms extends OverviewTerms {
    *   The current state of the form.
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
+    // Override the form if the taxonomy hierarchy manager has been set up.
+    if ($config = \Drupal::config('hierarchy_manager.hmconfig')) {
+      if ($allowed_setup_plugins = $config->get('allowed_setup_plugins')) {
+        // If the taxonomy setup plugin is enabled,
+        // override the submitForm function.
+        if (!empty($allowed_setup_plugins['hm_setup_taxonomy'])) {
+          // We don't need to do anything here,
+          // as the taxonomy plugin take it over.
+          return;
+        }
+      }
+    }
 
+    // The taxonomy setup plugin is not enabled.
+    // Let the submitForm function from core handle this request.
+    return parent::submitForm($form, $form_state);
   }
 
 }
-- 
GitLab