From 574861588a0ce86dd897cd3d04a71be58c081230 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Thu, 9 Aug 2018 10:54:08 +0800 Subject: [PATCH] MDL-62550 core_form: bring back the form item unique ids to fix js fails This id matches the id seen on the clean theme elements and is needed by the forms js. --- lib/outputrenderers.php | 16 ++++++++++++++++ .../core_form/element-template.mustache | 3 ++- theme/boost/upgrade.txt | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 7181ffee7a8..6ccfa79d09d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -4509,6 +4509,22 @@ EOD; } } + // Generate the form element wrapper ids and names to pass to the template. + // This differs between group and non-group elements. + if ($element->getType() === 'group') { + // Group element. + // The id will be something like 'fgroup_id_NAME'. E.g. fgroup_id_mygroup. + $elementcontext['wrapperid'] = $elementcontext['id']; + + // Ensure group elements pass through the group name as the element name so the id_error_{{element.name}} is + // properly set in the template. + $elementcontext['name'] = $elementcontext['groupname']; + } else { + // Non grouped element. + // Creates an id like 'fitem_id_NAME'. E.g. fitem_id_mytextelement. + $elementcontext['wrapperid'] = 'fitem_' . $elementcontext['id']; + } + $context = array( 'element' => $elementcontext, 'label' => $label, diff --git a/theme/boost/templates/core_form/element-template.mustache b/theme/boost/templates/core_form/element-template.mustache index 05ac446d821..80b7e0834ec 100644 --- a/theme/boost/templates/core_form/element-template.mustache +++ b/theme/boost/templates/core_form/element-template.mustache @@ -36,12 +36,13 @@ "advanced": false, "error": null, "element": { + "wrapperid": "fitem_id_fullname", "id": "id_fullname", "name": "fullname" } } }} -
+
{{#required}}{{#pix}}req, core, {{#str}}required{{/str}}{{/pix}}{{/required}} diff --git a/theme/boost/upgrade.txt b/theme/boost/upgrade.txt index ea2ecd05968..dddf8fd42b5 100644 --- a/theme/boost/upgrade.txt +++ b/theme/boost/upgrade.txt @@ -1,6 +1,14 @@ This file describes API changes in /theme/boost information provided here is intended especially for theme designers. +=== 3.7 === + +Form element template +--------------------- +A 'wrapperid' has been added to 'templates/core_form/element-template.mustache' to restore unique ids +on Boost form element wrappers. This restores the same unique element ids seen on elements in BS2 +themes, which were mistakenly dropped when introducing the Boost theme. + === 3.5 === The Boost theme now uses Bootstrap 4 Stable (BS4S). -- 2.43.0