diff --git a/includes/form.inc b/includes/form.inc index decca00..04d1362 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1741,6 +1741,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); @@ -3907,7 +3913,11 @@ function theme_form_element($variables) { } if (!empty($element['#description'])) { - $output .= '
' . $element['#description'] . "
\n"; + $attributes = array('class' => 'description'); + if (!empty($element['#id'])) { + $attributes['id'] = $element['#id'] . '--description'; + } + $output .= '' . $element['#description'] . "\n"; } $output .= "\n";