moodle/lib/form/templates/element-autocomplete-inline.mustache
sam marshall 14b1e93e85 MDL-80805 core_form: Accessibility - add aria-required to form fields
Most types of form field will now include aria-required="true" if the
field is marked as required. This causes assistive technology to inform
users that the field is required.

Before this change, in some cases (e.g. screen reader users tabbing
through fields) users were not informed that a field is required.
2024-02-15 14:30:33 +00:00

47 lines
1.8 KiB
Plaintext

{{< core_form/element-template-inline }}
{{$element}}
{{^element.frozen}}
{{#element.multiple}}
<input type="hidden" name="{{element.nameraw}}" value="_qf__force_multiselect_submission">
{{/element.multiple}}
<select class="custom-select {{#error}}is-invalid{{/error}}" name="{{element.name}}"
id="{{element.id}}"
{{#element.multiple}}multiple{{/element.multiple}}
{{#error}}
autofocus aria-describedby="{{element.iderror}}"
{{/error}}
{{#required}}
aria-required="true"
{{/required}}
{{{element.attributes}}} >
{{#element.options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}{{#html}} data-html="{{html}}"{{/html}}>{{{text}}}</option>
{{/element.options}}
</select>
{{/element.frozen}}
{{#element.frozen}}
{{#element.options}}
{{#selected}}
{{{text}}}
{{^element.hardfrozen}}
<input type="hidden" name="{{element.name}}" value="{{value}}">
{{/element.hardfrozen}}
{{/selected}}
{{/element.options}}
{{/element.frozen}}
{{/element}}
{{/ core_form/element-template-inline }}
{{^element.frozen}}
{{#js}}
require(['core/form-autocomplete'], function(module) {
module.enhance({{#quote}}#{{element.id}}{{/quote}},
{{element.tags}},
{{#quote}}{{element.ajax}}{{/quote}},
{{#quote}}{{element.placeholder}}{{/quote}},
{{element.casesensitive}},
{{element.showsuggestions}},
{{#quote}}{{element.noselectionstring}}{{/quote}});
});
{{/js}}
{{/element.frozen}}