Skip to content

Commit

Permalink
MDL-67544 form: Ensure that form errors have a unique id
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 6, 2020
1 parent 8092e7c commit f04c327
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/form/templatable_form_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ 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']);
$context['iderror'] = preg_replace('/_id_/', '_id_error_', $context['id']);
$context['iderror'] = preg_replace('/^id_/', 'id_error_', $context['iderror']);

// Elements with multiple values need array syntax.
if ($this->getAttribute('multiple')) {
Expand Down

0 comments on commit f04c327

Please sign in to comment.