From bc9dd78b2fedda1550746f8b328e143a748b7ab8 Mon Sep 17 00:00:00 2001
From: Eric Bremner <ebremner@uwaterloo.ca>
Date: Wed, 31 Jan 2024 14:19:41 -0500
Subject: [PATCH] ISTWCMS-6711: fixing the form field id for details label

---
 templates/elements/details.html.twig |  2 +-
 uw_fdsu_theme_resp.theme             | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/templates/elements/details.html.twig b/templates/elements/details.html.twig
index 9afefced..07ab4915 100644
--- a/templates/elements/details.html.twig
+++ b/templates/elements/details.html.twig
@@ -30,7 +30,7 @@ Prefix 'details' class to avoid collision with Modernizr.
     ]
     %}
     <summary{{ summary_attributes.addClass(summary_classes) }}>
-      <label for="{{ element['#id'] }}">{{ title }}</label>
+      <label for="{{ form_field_id }}">{{ title }}</label>
     </summary>
   {%- endif -%}
   <div class="seven-details__wrapper details-wrapper">
diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme
index cdec19c6..05f12bf9 100644
--- a/uw_fdsu_theme_resp.theme
+++ b/uw_fdsu_theme_resp.theme
@@ -687,3 +687,17 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) {
     }
   }
 }
+
+/**
+ * Implements template_preprocess_details().
+ */
+function uw_fdsu_theme_resp_preprocess_details(&$variables) {
+
+  // Add the form field id to the variables.
+  // This comes from ISTWCMS-6711, we are
+  // removing the -collapsible if there is
+  // one there and using the html id.  If there
+  // is no -collapsible, it will just use the
+  // html id.
+  $variables['form_field_id'] = str_replace('-collapsible', '', $variables['attributes']['id']);
+}
-- 
GitLab