Commit 8a14b893 authored by webchick's avatar webchick

Issue #2273671 by JeroenT, mgifford, Tim Bozeman, StryKaizer, catch: Allowed...

Issue #2273671 by JeroenT, mgifford, Tim Bozeman, StryKaizer, catch: Allowed number of values more than 1 needs aria-describedby Support
parent b332f08e
......@@ -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();
......
......@@ -254,6 +254,10 @@ function testFieldFormUnlimited() {
$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');
......
......@@ -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>
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment