summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-10-05 06:11:14 (GMT)
committerwebchick2015-10-05 06:11:14 (GMT)
commit8a14b89391d22e273d671d6a8e1fb2ee8ddc08a6 (patch)
treebca27761bc8ab54317229fcb15af569d4d601c64
parentb332f08e6a3cbcef8ece57af97e2ac69e749018a (diff)
Issue #2273671 by JeroenT, mgifford, Tim Bozeman, StryKaizer, catch: Allowed number of values more than 1 needs aria-describedby Support
-rw-r--r--core/includes/theme.inc10
-rw-r--r--core/modules/field/src/Tests/FormTest.php4
-rw-r--r--core/modules/system/templates/field-multiple-value-form.html.twig8
-rw-r--r--core/themes/classy/templates/form/field-multiple-value-form.html.twig8
4 files changed, 23 insertions, 7 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 41c9e85..a7c8166 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1659,7 +1659,15 @@ function template_preprocess_field_multiple_value_form(&$variables) {
),
);
- $variables['description'] = $element['#description'];
+ if (!empty($element['#description'])) {
+ $description_id = $element['#attributes']['aria-describedby'];
+ $description_attributes['id'] = $description_id;
+ $variables['description']['attributes'] = new Attribute($description_attributes);
+ $variables['description']['content'] = $element['#description'];
+
+ // Add the description's id to the table aria attributes.
+ $variables['table']['#attributes']['aria-describedby'] = $element['#attributes']['aria-describedby'];
+ }
}
else {
$variables['elements'] = array();
diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php
index 0ae049b..9e70b38 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -254,6 +254,10 @@ class FormTest extends FieldTestBase {
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
+ // Check if aria-describedby attribute is placed on multiple value widgets.
+ $elements = $this->xpath('//table[@id="field-unlimited-values" and @aria-describedby="edit-field-unlimited--description"]');
+ $this->assertTrue(isset($elements[0]), t('aria-describedby attribute is properly placed on multiple value widgets.'));
+
// Press 'add more' button -> 2 widgets.
$this->drupalPostForm(NULL, array(), t('Add another item'));
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
diff --git a/core/modules/system/templates/field-multiple-value-form.html.twig b/core/modules/system/templates/field-multiple-value-form.html.twig
index 348621c..1108d6e 100644
--- a/core/modules/system/templates/field-multiple-value-form.html.twig
+++ b/core/modules/system/templates/field-multiple-value-form.html.twig
@@ -11,7 +11,9 @@
*
* Available variables when there are multiple fields.
* - table: Table of field items.
- * - description: Description text for the form element.
+ * - description: The description element containing the following properties:
+ * - content: The description content of the form element.
+ * - attributes: HTML attributes to apply to the description container.
* - button: "Add another item" button.
*
* @see template_preprocess_field_multiple_value_form()
@@ -22,8 +24,8 @@
{% if multiple %}
<div class="js-form-item form-item">
{{ table }}
- {% if description %}
- <div class="description">{{ description }}</div>
+ {% if description.content %}
+ <div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
{% endif %}
{% if button %}
<div class="clearfix">{{ button }}</div>
diff --git a/core/themes/classy/templates/form/field-multiple-value-form.html.twig b/core/themes/classy/templates/form/field-multiple-value-form.html.twig
index bcc7b89..6ac2ddf 100644
--- a/core/themes/classy/templates/form/field-multiple-value-form.html.twig
+++ b/core/themes/classy/templates/form/field-multiple-value-form.html.twig
@@ -11,7 +11,9 @@
*
* Available variables when there are multiple fields.
* - table: Table of field items.
- * - description: Description text for the form element.
+ * - description: The description element containing the following properties:
+ * - content: The description content of the form element.
+ * - attributes: HTML attributes to apply to the description container.
* - button: "Add another item" button.
*
* @see template_preprocess_field_multiple_value_form()
@@ -20,8 +22,8 @@
{% if multiple %}
<div class="js-form-item form-item">
{{ table }}
- {% if description %}
- <div class="description">{{ description }}</div>
+ {% if description.content %}
+ <div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
{% endif %}
{% if button %}
<div class="clearfix">{{ button }}</div>