Created
September 11, 2018 14:53
-
-
Save jodyHamilton/08fa2da153061a118ebc7b4d76e11a8e to your computer and use it in GitHub Desktop.
aria describedby errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig b/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig | |
index 9e6cc85d6..18523d252 100644 | |
--- a/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig | |
+++ b/web/themes/custom/lsac/components/_patterns/01-atoms/form-elements/form-element/form-element.twig | |
@@ -79,6 +79,7 @@ | |
{{ description.content }} | |
</div> | |
{% endif %} | |
+ {{ kint(children) }} | |
{{ children }} | |
{% if suffix is not empty %} | |
<span class="field-suffix">{{ suffix }}</span> | |
@@ -87,7 +88,7 @@ | |
{{ label }} | |
{% endif %} | |
{% if errors %} | |
- <div class="form-item--error-message"> | |
+ <div class="form-item--error-message" id="{{name|clean_class}}--error"> | |
<strong>{{ errors }}</strong> | |
</div> | |
{% endif %} | |
diff --git a/web/themes/custom/lsac/templates/01-atoms/input.html.twig b/web/themes/custom/lsac/templates/01-atoms/input.html.twig | |
index a065161e9..39000fe4a 100644 | |
--- a/web/themes/custom/lsac/templates/01-atoms/input.html.twig | |
+++ b/web/themes/custom/lsac/templates/01-atoms/input.html.twig | |
@@ -1 +1,8 @@ | |
+{% if element["#errors"] %} | |
+ {% set attributes = attributes.setAttribute('aria-describedby', element["#name"]|clean_class ~ '--error' ) %} | |
+{% endif %} | |
+ | |
{% include "@atoms/form-elements/input/input.twig" %} | |
+ | |
+ | |
+{{ kint() }} | |
(END) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment