From 5e30494edb3fbf5682416e6f41c8687e24c80130 Mon Sep 17 00:00:00 2001 From: webchick Date: Sat, 10 Aug 2013 01:46:10 -0700 Subject: [PATCH] Issue #2047075 by Caecus, mgifford, jessebeach, larowlan: Mark invalid form field with [aria-invalid=true]. --- core/includes/form.inc | 1 + core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/core/includes/form.inc b/core/includes/form.inc index a789322f95f..d63596ec268 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -4842,6 +4842,7 @@ function _form_set_attributes(&$element, $class = array()) { } if (isset($element['#parents']) && form_get_error($element) !== NULL && !empty($element['#validated'])) { $element['#attributes']['class'][] = 'error'; + $element['#attributes']['aria-invalid'] = 'true'; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php index f402395d5f6..fecc0b8349d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php @@ -248,6 +248,9 @@ class FormTest extends WebTestBase { // Check the page for the error class on the textfield. $this->assertFieldByXPath('//input[contains(@class, "error")]', FALSE, 'Error input form element class found.'); + // Check the page for the aria-invalid attribute on the textfield. + $this->assertFieldByXPath('//input[contains(@aria-invalid, "true")]', FALSE, 'Aria invalid attribute found.'); + // Submit again with required fields set and verify that there are no // error messages. $edit = array(