Skip to content

Instantly share code, notes, and snippets.

@jodyHamilton
Created September 11, 2018 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodyHamilton/08fa2da153061a118ebc7b4d76e11a8e to your computer and use it in GitHub Desktop.
Save jodyHamilton/08fa2da153061a118ebc7b4d76e11a8e to your computer and use it in GitHub Desktop.
aria describedby errors
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