diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-07 04:39:59 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-07 04:39:59 +0000 |
commit | 8173fc1aa338a21bc2ea119fba37437cf3209a44 (patch) | |
tree | 74a6cb2c00c2108dcfe839c8b9514023421a6ab7 /includes | |
parent | ba96cffdb7d3f76254ff7391523a6fc34abf10e2 (diff) | |
download | brdo-8173fc1aa338a21bc2ea119fba37437cf3209a44.tar.gz brdo-8173fc1aa338a21bc2ea119fba37437cf3209a44.tar.bz2 |
- Patch #558928 by mgifford, brandonojc, Owen Barton, Everett Zufelt: follow-up on making form element labeling more accessible.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/form.inc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/includes/form.inc b/includes/form.inc index 203afe985..3fe577a77 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -2986,6 +2986,9 @@ function theme_file($variables) { * for radio and checkbox #type elements as set in system_element_info(). * If the #title is empty but the field is #required, the label will * contain only the required marker. + * - invisible: Labels are critical for screen readers to enable them to + * properly navigate through forms but can be visually distracting. This + * property hides the label for everyone except screen readers. * - attribute: Set the title attribute on the element to create a tooltip * but output no label element. This is supported only for checkboxes * and radios in form_pre_render_conditional_form_element(). It is used @@ -3042,6 +3045,7 @@ function theme_form_element($variables) { $output .= ' ' . $element['#children'] . "\n"; break; + case 'invisible': case 'after': $output .= ' ' . $element['#children']; $output .= ' ' . theme('form_element_label', $variables) . "\n"; @@ -3128,10 +3132,15 @@ function theme_form_element_label($variables) { $title = filter_xss_admin($element['#title']); $attributes = array(); + // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after') { - // Style the label as class option to display inline with the element. $attributes['class'] = 'option'; } + // Show label only to screen readers to avoid disruption in visual flows. + elseif ($element['#title_display'] == 'invisible') { + $attributes['class'] = 'element-invisible'; + } + if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } |