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.
This commit is contained in:
Jake Dallimore 2018-08-09 10:54:08 +08:00
parent 38a1b4f203
commit 574861588a
3 changed files with 26 additions and 1 deletions

View File

@ -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,

View File

@ -36,12 +36,13 @@
"advanced": false,
"error": null,
"element": {
"wrapperid": "fitem_id_fullname",
"id": "id_fullname",
"name": "fullname"
}
}
}}
<div class="form-group row {{#error}}has-danger{{/error}} fitem {{#element.emptylabel}}femptylabel{{/element.emptylabel}} {{#advanced}}advanced{{/advanced}} {{{element.extraclasses}}}" {{#element.groupname}}data-groupname="{{.}}"{{/element.groupname}}>
<div id="{{element.wrapperid}}" class="form-group row {{#error}}has-danger{{/error}} fitem {{#element.emptylabel}}femptylabel{{/element.emptylabel}} {{#advanced}}advanced{{/advanced}} {{{element.extraclasses}}}" {{#element.groupname}}data-groupname="{{.}}"{{/element.groupname}}>
<div class="col-md-3">
<span class="float-sm-right text-nowrap">
{{#required}}<abbr class="initialism text-danger" title="{{#str}}required{{/str}}">{{#pix}}req, core, {{#str}}required{{/str}}{{/pix}}</abbr>{{/required}}

View File

@ -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).