Commit 16ad612c authored by catch's avatar catch

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
......@@ -1779,6 +1779,12 @@ function form_builder($form_id, &$element, &$form_state) {
if (!isset($element['#id'])) {
$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.
if (!empty($element['#input'])) {
_form_builder_handle_input_element($form_id, $element, $form_state);
......@@ -4186,7 +4192,11 @@ function theme_form_element($variables) {
}
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";
......
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