Skip to content

Commit

Permalink
MDL-65217 form: id for error area
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Apr 29, 2019
1 parent 086aa54 commit 521989e
Show file tree
Hide file tree
Showing 28 changed files with 34 additions and 34 deletions.
1 change: 1 addition & 0 deletions lib/form/templatable_form_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function export_for_template(renderer_base $output) {
$context['type'] = $this->getType();
$context['attributes'] = implode(' ', $otherattributes);
$context['emptylabel'] = ($this->getLabel() === '');
$context['iderror'] = preg_replace('/^id_/', 'id_error_', $context['id']);

// Elements with multiple values need array syntax.
if ($this->getAttribute('multiple')) {
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-advcheckbox-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{#element.checked}}checked{{/element.checked}}
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#element.frozen}}
disabled
Expand All @@ -27,7 +27,7 @@
<em>{{{.}}}</em>
{{/text}}
{{{helpbutton}}}
<span class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<span class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</span>
{{^element.frozen}}
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-advcheckbox.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{/element.selectedvalue}}
id="{{element.id}}" {{#element.checked}}checked{{/element.checked}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#element.frozen}}
disabled
Expand All @@ -43,7 +43,7 @@
{{{helpbutton}}}
</span>
</div>
<div class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<div class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-autocomplete-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-autocomplete.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-button-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
id="{{element.id}}"
type="button"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}}
>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-button.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
id="{{element.id}}"
type="button"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}}>
{{{element.value}}}
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-checkbox-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{#element.checked}}checked{{/element.checked}}
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#element.frozen}}
disabled
Expand All @@ -27,7 +27,7 @@
<em>{{{.}}}</em>
{{/text}}
{{{helpbutton}}}
<span class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<span class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</span>
{{^element.frozen}}
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-checkbox.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{/element.value}}
id="{{element.id}}" {{#element.checked}}checked{{/element.checked}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#element.frozen}}
disabled
Expand All @@ -43,7 +43,7 @@
{{{helpbutton}}}
</span>
</div>
<div class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<div class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-password.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
value="{{element.value}}"
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}} {{{element.attributes}}}>
{{/element.frozen}}
{{/element}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-passwordunmask.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
class="form-control d-inline-block {{# error }}is-invalid{{/ error }}"
data-size="{{ element.size }}"
{{# error }}
autofocus aria-describedby="id_error_{{ element.name }}"
autofocus aria-describedby="{{ element.iderror }}"
{{/ error }}
{{{ attributes }}}
>
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-radio-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{#element.checked}}checked{{/element.checked}}
{{#element.frozen}}disabled{{/element.frozen}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{{label}}}
Expand All @@ -28,7 +28,7 @@
<em>{{{.}}}</em>
{{/text}}
{{{helpbutton}}}
<span class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<span class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</span>
{{^element.frozen}}
Expand Down
4 changes: 2 additions & 2 deletions lib/form/templates/element-radio.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{{#element.checked}}checked{{/element.checked}}
{{#element.frozen}}disabled{{/element.frozen}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}} {{{element.attributes}}} >
{{#text}}
{{{.}}}
Expand All @@ -44,7 +44,7 @@
{{{helpbutton}}}
</span>
</div>
<div class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<div class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-select-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple size="{{element.size}}"{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-select.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple size="{{element.size}}"{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-selectgroups-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.optiongroups}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-selectgroups.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.optiongroups}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-selectwithlink.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-submit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name="{{element.name}}"
id="{{element.id}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
value="{{element.value}}"
{{{element.attributes}}} >
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-tags-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-tags.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{#element.options}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-template-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Element goes here -->
{{/ element }}
</span>
<div class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<div class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{{$ element }}
<!-- Element goes here -->
{{/ element }}
<div class="form-control-feedback invalid-feedback" id="id_error_{{element.name}}" {{#error}} style="display: block;"{{/error}}>
<div class="form-control-feedback invalid-feedback" id="{{element.iderror}}" {{#error}} style="display: block;"{{/error}}>
{{{error}}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-text-inline.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
value="{{element.value}}"
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}}>
{{/element}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-text.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
value="{{element.value}}"
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >
{{/element}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-textarea.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
id="{{element.id}}"
class="form-control {{#error}}is-invalid{{/error}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{{element.attributes}}} >{{element.value}}</textarea>
{{/element.frozen}}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/templates/element-url.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
value="{{element.value}}"
size="{{element.size}}"
{{#error}}
autofocus aria-describedby="id_error_{{element.name}}"
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#element.frozen}}
readonly {{#element.hardfrozen}}disabled{{/element.hardfrozen}}
Expand Down
3 changes: 1 addition & 2 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4593,8 +4593,7 @@ public function mform_element($element, $required, $advanced, $error, $ingroup)
// 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.
// Ensure group elements pass through the group name as the element name.
$elementcontext['name'] = $elementcontext['groupname'];
} else {
// Non grouped element.
Expand Down

0 comments on commit 521989e

Please sign in to comment.