Skip to content
Snippets Groups Projects
Commit 16ad612c authored by catch's avatar catch
Browse files

Issue #405360 by Liam Morland, mgifford, Everett Zufelt: Added Use...

Issue #405360 by Liam Morland, mgifford, Everett Zufelt: Added Use aria-describedby to link form elements with form element descriptions.
parent 837430ff
No related branches found
No related tags found
No related merge requests found
...@@ -1779,6 +1779,12 @@ function form_builder($form_id, &$element, &$form_state) { ...@@ -1779,6 +1779,12 @@ function form_builder($form_id, &$element, &$form_state) {
if (!isset($element['#id'])) { if (!isset($element['#id'])) {
$element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents'])); $element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents']));
} }
// Add the aria-describedby attribute to associate the form control with its
// description.
if (!empty($element['#description'])) {
$element['#attributes']['aria-describedby'] = $element['#id'] . '--description';
}
// Handle input elements. // Handle input elements.
if (!empty($element['#input'])) { if (!empty($element['#input'])) {
_form_builder_handle_input_element($form_id, $element, $form_state); _form_builder_handle_input_element($form_id, $element, $form_state);
...@@ -4186,7 +4192,11 @@ function theme_form_element($variables) { ...@@ -4186,7 +4192,11 @@ function theme_form_element($variables) {
} }
if (!empty($element['#description'])) { if (!empty($element['#description'])) {
$output .= '<div class="description">' . $element['#description'] . "</div>\n"; $attributes = array('class' => 'description');
if (!empty($element['#id'])) {
$attributes['id'] = $element['#id'] . '--description';
}
$output .= '<div' . drupal_attributes($attributes) . '>' . $element['#description'] . "</div>\n";
} }
$output .= "</div>\n"; $output .= "</div>\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment