From 425c9c23681e55f33f605939c207408f89dea91f Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Fri, 10 Apr 2026 17:35:18 +0100 Subject: [PATCH 1/6] fix: Added missing error class for checkbox validation errors. --- src/Resources/views/Form/accessible-forms.html.twig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Resources/views/Form/accessible-forms.html.twig b/src/Resources/views/Form/accessible-forms.html.twig index 2191d6e..92bff23 100644 --- a/src/Resources/views/Form/accessible-forms.html.twig +++ b/src/Resources/views/Form/accessible-forms.html.twig @@ -124,7 +124,10 @@ {# This is for single non-choice checkboxes (eg. Agree to Terms) #} {% block checkbox_row %} -
+
+ {%- if errors -%} + {{ errors }} + {%- endif -%}
{{- form_widget(form, row_attr) -}} From b400ca00f613ca8bb2bd1fdf86e088698b44563c Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Fri, 10 Apr 2026 18:00:23 +0100 Subject: [PATCH 2/6] fix: Fixed issue with multiple errors for a single field being grouped onto one. --- src/Twig/AccessibleFormsExtension.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Twig/AccessibleFormsExtension.php b/src/Twig/AccessibleFormsExtension.php index 24add7b..e97a56b 100644 --- a/src/Twig/AccessibleFormsExtension.php +++ b/src/Twig/AccessibleFormsExtension.php @@ -58,11 +58,20 @@ public function allErrors(FormView $form): array $errors = []; foreach ($form->children as $child) { if (isset($child->vars['errors']) && count($child->vars['errors']) > 0) { - $errors[] = [ - 'id' => $child->vars['id'], - 'name' => $child->vars['full_name'], - 'message' => (string) $child->vars['errors'] - ]; + + $fieldErrors = explode('ERROR: ', (string) $child->vars['errors']); + + foreach ($fieldErrors as $fieldError) { + if (!$fieldError) { + continue; + } + + $errors[] = [ + 'id' => $child->vars['id'], + 'name' => $child->vars['full_name'], + 'message' => 'Error: ' . $fieldError + ]; + } } } $form->vars['children_errors'] = $errors; From b34e0deedcbc952d19d281ccac35327d85398b81 Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Fri, 12 Jun 2026 15:27:11 +0100 Subject: [PATCH 3/6] fix: Disabled mapping by default on custom HTML block. --- src/FieldTypes/Html.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FieldTypes/Html.php b/src/FieldTypes/Html.php index a930cc0..ff863c6 100644 --- a/src/FieldTypes/Html.php +++ b/src/FieldTypes/Html.php @@ -13,8 +13,9 @@ class Html extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ + 'mapped' => false, 'html' => null, - 'view' => null + 'view' => null, ]); } From dfe48e0ec9bdcca950b600a3db4074e33ed02ebe Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Fri, 12 Jun 2026 16:13:42 +0100 Subject: [PATCH 4/6] Moved fieldset to expanded choice block for compound fields, added attributes so that it picks up aria-describedby fields correctly. --- .../views/Form/accessible-forms.html.twig | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Resources/views/Form/accessible-forms.html.twig b/src/Resources/views/Form/accessible-forms.html.twig index 92bff23..402067b 100644 --- a/src/Resources/views/Form/accessible-forms.html.twig +++ b/src/Resources/views/Form/accessible-forms.html.twig @@ -109,16 +109,10 @@ {# Adjust order of elements in form row, add fieldset for compound groups #} {%- block form_row_render -%} - {% if compound %} -
- {% endif %} - {{- form_label(form) -}} - {{- form_help(form) -}} - {{- form_errors(form) -}} - {{- form_widget(form, widget_attr) -}} - {% if compound %} -
- {% endif %} + {{- form_label(form) -}} + {{- form_help(form) -}} + {{- form_errors(form) -}} + {{- form_widget(form, widget_attr) -}}
{%- endblock form_row_render -%} @@ -139,16 +133,26 @@ {# Add custom markup to checkbox / radio buttons in choice context #} {%- block choice_widget_expanded -%} -
-
- {%- for child in form %} -
- {{- form_widget(child) -}} - {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} -
- {% endfor -%} -
+ {% if compound %} +
+ {% else %} +
+ {% endif %} + +
+ {%- for child in form %} +
+ {{- form_widget(child) -}} + {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} +
+ {% endfor -%}
+ + {% if compound %} +
+ {% else %} +
+ {% endif %} {%- endblock choice_widget_expanded -%} {# Add class to checkboxes #} From 3f4254a0f34c0a17d32313f63e300d30afe04f2d Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Mon, 15 Jun 2026 17:01:42 +0100 Subject: [PATCH 5/6] fix: Append _0 to error ID on checkbox and radio button groups, so that the error link jumps to the first input element instead of the surrounding block. --- src/Twig/AccessibleFormsExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Twig/AccessibleFormsExtension.php b/src/Twig/AccessibleFormsExtension.php index e97a56b..f4aafbf 100644 --- a/src/Twig/AccessibleFormsExtension.php +++ b/src/Twig/AccessibleFormsExtension.php @@ -59,6 +59,12 @@ public function allErrors(FormView $form): array foreach ($form->children as $child) { if (isset($child->vars['errors']) && count($child->vars['errors']) > 0) { + $id = $child->vars['id']; + + if (!empty($child->vars['choices']) && !empty($child->vars['expanded']) && $child->vars['expanded'] === true) { + $id .= '_0'; + } + $fieldErrors = explode('ERROR: ', (string) $child->vars['errors']); foreach ($fieldErrors as $fieldError) { @@ -67,7 +73,7 @@ public function allErrors(FormView $form): array } $errors[] = [ - 'id' => $child->vars['id'], + 'id' => $id, 'name' => $child->vars['full_name'], 'message' => 'Error: ' . $fieldError ]; From 36d38e175bd51fd88a57415bd9ea7b5c910cdbc5 Mon Sep 17 00:00:00 2001 From: Gareth Trinkwon Date: Wed, 17 Jun 2026 09:24:21 +0100 Subject: [PATCH 6/6] Update CHANGELOG for version 0.1.4 Document changes for version 0.1.4, including bug fixes for custom Html block type, fieldset elements, validation errors, and error summary highlighting. --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3bbfd9..466a24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to accessible-forms will be documented in this file. +## [0.1.3](https://github.com/studio24/accessible-forms/compare/v0.1.3...v0.1.4) (2026-04-10) + +### Bug Fixes + +* Set mapped to false by default for custom Html block type, to prevent the need to do so manually. +* Moved choice fieldset element from form_row_render to choice_widget_expanded to allow checkbox attributes to be added to fieldset. (solves issue where screen readers were not announcing errors on checkbox/radio focus) +* Fixed multiple validation errors for one field being listed as one error and appended to the same string. +* Appended _0 to the error block so that the first checkbox/radio is highlighted when clicking the error summary anchor. + + ## [0.1.3](https://github.com/studio24/accessible-forms/compare/v0.1.2...v0.1.3) (2026-04-10) ### Bug Fixes