Download & Extend

Administer > Modules pages make improper use of form labels

Project:Drupal core
Version:7.x-dev
Component:system.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:#d7ux

Issue Summary

The modules install page has label tags around the module names, making them easy to select/deselect (and, for non-sighted folks, making the form easier to use). The uninstall page does not have said labels. It's a convenience thing for me, but it could be an accessibility thing for others.

Comments

#1

Title:Module Uninstall Page Missing HTML Form Labels» Administer > Modules pages make improper use of form labels
Version:6.x-dev» 7.x-dev
Component:markup» base system

I have moved this to base and d7 because the form labels on the Administer > Modules page are improper there and the solution can hopefully be back ported.

In Drupal 7 on the Module List and Uninstall pages both the checkbox and module name are enclosed in a label. Both labels for attribute point to the id of the checkbox input element. This does not work with many screen-readers as they are expecting only one label per form field and default to using the first label, which has no associated text or title to be communicated to the user.

The current code:

Modules List

<label class="option" for="edit-modules-Core-aggregator-enable"><input type="checkbox" name="modules[Core][aggregator][enable]" id="edit-modules-Core-aggregator-enable"
value="1"   class="form-checkbox" /> </label>

<label for="edit-modules-Core-aggregator-enable"><strong>Aggregator</strong></label>

Modules Uninstall

<label class="option" for="edit-uninstall-aggregator"><input type="checkbox" name="uninstall[aggregator]" id="edit-uninstall-aggregator" value="aggregator"
  class="form-checkbox" /> </label>

<strong><label for="edit-uninstall-aggregator">Aggregator</label></strong>

Recommended changes

To clarify either of the following options would allow for a screen-reader to find appropriate information to communicate to the user. I have used the above two code segments and shown the two markup options, one for each.

Wrapping only the module name in a label

<input type="checkbox" name="modules[Core][aggregator][enable]" id="edit-modules-Core-aggregator-enable"
value="1"   class="form-checkbox" />

<label for="edit-modules-Core-aggregator-enable"><strong>Aggregator</strong></label>

The only modification in the above example is to remove the label that encloses the checkbox, this may not be possible without a change to fapi

Using the title attribute

<label class="option" for="edit-uninstall-aggregator"><input type="checkbox" title="Aggregator" name="uninstall[aggregator]" id="edit-uninstall-aggregator" value="aggregator"
  class="form-checkbox" /> </label>
<strong>Aggregator</strong>

There are two modifications in the above example. The first is to add title="Aggregator" to the checkbox input field, the second is to remove the label that encloses the module name.

#2

#3

This patch is localized to modules/system/system.admin.inc: system_modules_build_row() and should resolve all problems related to this issue that are not covered by the blocker issue #522772: Improve radio and checkbox title and labeling features for accessibility.

1. Removes label elements that wrap the module name on administer > build > modules : list and uninstall

2. Sets the #title property of the checkbox elements to the module name. This will not appear in the page source when rendered because of the blocker issue.

AttachmentSizeStatusTest resultOperations
issue-501444.patch1.89 KBIdleFailed: Failed to apply patch.View details

#4

Status:active» needs review

#5

This new patch leaves label wrapped around the module name, but removes all setting of the #title property for the checkbox element. This means that theme_checkbox will not produce a label for the checkbox and the properly associated label wrapped around the module name will be recognized by assistive technology.

AttachmentSizeStatusTest resultOperations
issue-501444.patch985 bytesIdleFailed: Failed to apply patch.View details

#6

Status:needs review» postponed

Working on a new approach. Leaving this issue until #522772: Improve radio and checkbox title and labeling features for accessibility is fixed.

#7

Status:postponed» needs review

Determined the best current solution that is not blocked by #522772: Improve radio and checkbox title and labeling features for accessibility.

Issue:
On admin > build > modules (list and uninstall tabs) both the checkbox input element and module name are wrapped in label elements with for attribute set to the id of the checkbox element. This confuses screen-readers and no information is communicated to the screen-reader user.

Solution:

1. includes/form.inc: Modified theme_radio and theme_checkbox to only output label element if $element['#title'] is not empty, was set to if not null. This was outputting labels even when the title attribute was an empty string value.

2. modules/system/system.admin.inc: _system_modules_build_row: Removed line of code that sets #title property for checkbox to 'Enabled', as this is unset in theme_system_modules_fieldset

3. modules/system/system.admin.inc: theme_system_modules_fieldset: removed line of code that unsets $element['#title'] as it is no longer being set (see 2 above).

Summary:
As the #title is no longer being set for the checkbox, and since theme_checkbox (and theme_radio) will now only output labels on non-empty #title attributes, only the module name receives a label wrapper.

AttachmentSizeStatusTest resultOperations
issue-501444.patch2.13 KBIdleFailed: Failed to apply patch.View details

#8

Component:base system» system.module

Changing the component as administer > build > modules is part of system.module

#9

Status:needs review» needs work

The last submitted patch failed testing.

#10

Status:needs work» needs review

Would like to have this issue resolved. Here's a rerolled patch.

AttachmentSizeStatusTest resultOperations
issue-501444_2.patch2.14 KBIdleFailed: 12334 passes, 4 fails, 0 exceptionsView details

#11

Status:needs review» needs work

The last submitted patch failed testing.

#12

Fixed by latest patch for #558928: Form element labeling is inconsistent, inflexible and bad for accessibility (see comment #68), which has not yet been set to RTBC. Can anyone review that patch and either vouch that it is RTBC or fix any minor deficiencies to get it there?

Fixing these issues will make D7 a viable option for many governments and governmental agencies throughout North America, the United Kingdom, and the rest of Europe — anywhere that accessibility is required of them by law. This patch is a major step towards ensuring that Drupal can produce accessible Web sites.

#13

Status:needs work» needs review

I'm setting this back to needs review as my local install of this patch didn't produce any errors in simpletest.

#14

#15

I would think so. Other votes?

#16

Status:needs review» postponed

Let's keep this open until #558928: Form element labeling is inconsistent, inflexible and bad for accessibility is fixed.

#17

Tagging #d7ux

#18

subscribing

#19

Status:postponed» fixed

It's in core now with http://drupal.org/node/558928#comment-2328352

#20

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.