When you configure a form label to be hidden via the webform component UI, the label tag is hidden. However, no "title" attribute exists on the form field itself making it difficult for users using screen readers to determine what the field is actually for.
The WCAG 2.0 guidelines at http://www.w3.org/TR/2010/NOTE-WCAG20-TECHS-20101014/H65.html recommends the use of the "title" attribute to label form controls when the visual design cannot accommodate the label
.
Attached patch fixes this issue for Drupal 6.
I'll provide a patch for Drupal 7 version later today hopefully.
Comments
Comment #1
stella CreditAttribution: stella commentedHere's a D7 version too. This one can one step further and still print the label tag but with the new D7 "element-invisible" class.
Comment #2
quicksketchThanks stella, I haven't had time to look at this patch so it got buried in the Webform queue. The D6 patch looks pretty good.
In the D7 patch, this doesn't seem to make any sense, why would you run check_plain() on a property that doesn't exist? Even if the logic is inverted, what's this providing?
It'd probably be better to move this bit of code up above the setting of the $element variable.
Comment #3
stella CreditAttribution: stella commentedNow I'm confused. Does
$component['name']
not exist here?The code is essentially the same as the D6 version, which says if there is no value set for
$component['extra']['attributes']['title']
, then use the sanitized$component['name']
.Maybe I'm missing something here, but I don't see how it differs from the D6 patch you approved.
Comment #4
quicksketchOh, for some reason I thought the code was this, just setting the property to itself:
I'm just being crazy apparently. I'll take another look at this.
Comment #5
stella CreditAttribution: stella commentedHi Nate, did you have a chance to review this again? Fixing status.
Comment #6
mgiffordThe title attribute is certainly a good way to do this. In D7 you can also just add
'#title_display' => 'invisible',
when defining the form element and it will be hidden to the display, but also accessible to screen readers. It doesn't use the title attribute, but it still meets WCAG 2.0 AA guidelines.Comment #7
Liam MorlandReroll.
Comment #8
mgiffordThat works well. I spun up an instance with SimplyTest.me and grabbed this screenshot:
Thanks for pushing this ahead Liam.
Comment #9
Liam MorlandComment #10
carwin CreditAttribution: carwin commentedThanks Liam and stella, this is committed to the 7.x-4.x branch.
Comment #11
mgiffordThanks!
Comment #12
quicksketchThis patch introduced a Notice error when creating components: #2020705: Notice: Undefined index: name in webform_component_defaults().
Comment #13
andrewmacpherson CreditAttribution: andrewmacpherson commentedRe-rolling for people still using 7.x-3.x (the patches above no longer apply).
Are backports to 7.x-3.x still being considered?
Comment #14
quicksketchSure @andrewmacpherson, I think this would be valid for backporting. Thanks for the reroll. I'm not updating the 7.x-3.x as frequently as the 7.x-4.x branch, but I'll make sure this gets in next time I'm reviewing patches.
Comment #15
mgiffordDid this get in 7.x-4.0-beta1?
Comment #16
Liam MorlandYes.
Comment #17
quicksketchThe 4.x patch was causing PHP notices apparently. This patch was revised in #2020705: Notice: Undefined index: name in webform_component_defaults() to work in a more graceful manner. The 3.x backport no longer applies and should use the same approach used in that fix. Really I'd prefer to just say, "use 4.x", but if this patch is rerolled for 3.x it'll get in eventually.
Comment #18
mgiffordAt this rate, it looks like the 4.x branch is going to be out before we get a patch for this issue into 3.x.
That's fine with me. Thanks for fixing the PHP notices.
Comment #19
rreiss CreditAttribution: rreiss commented#13 Works for me. Thanks!
Comment #20
DanChadwick CreditAttribution: DanChadwick commented7.x-3.x is receiving critical fixes only.
Comment #21
tlyngej CreditAttribution: tlyngej commentedFor those in need, here is a reroll of the patch that applies to 3.23
Comment #22
Liam MorlandThis is fixed in 7.x-4.x.
Comment #23
SpokjeReroll of patch in #21 against the latest HEAD of the 7.x-3.x branch.