My webform created with the webform module gives the following warning on the date field when validated with W3C Markup Validation Service :

Validation Output: 1 Warning

Below is a list of the warning message(s) produced when checking your document.

1. Warning Line 97, Column 14: reference to non-existent ID "edit-submitted-wanneer-gestart"

       <label for="edit-submitted-wanneer-gestart">Wanneer is uw bedrijf gestart: <sp…

      This error can be triggered by:
          * A non-existent input, select or textarea element
          * A missing id attribute
          * A typographical error in the id attribute

      Try to check the spelling and case of the id you are referring to.

This is my form:

My webform

And so it is validated:

W3C Validation of My Webform

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Priority: Normal » Minor

Hmm, this is because date fields aren't just one field, they're 3. So you can't use an ID to target all of them at once. We'll need to figure out a way to disable the target attribute while still keeping the ID on the field.

quicksketch’s picture

This problem may also affect Time and Grid components.

4ud’s picture

Version: 6.x-3.2 » 6.x-3.6
FileSize
53.94 KB

The same problem still in version 3.6.

4ud’s picture

Is there a way to fix this?

Thx

quicksketch’s picture

There is not an "easy" solution here that I know of, since Webform does not have the level of control needed on the output of form elements in Drupal 6. In Drupal 6, the "target" attribute is output by theme_form_element(), which is part of core. In Drupal 7 we point this to theme_webform_element() instead, but in both cases we haven't yet solved the problem.

4ud’s picture

Okay I understand. Thank you for your fast answer!

robertom’s picture

Title: W3C validation gives warning on date field » W3C validation gives warning on composed component
Version: 6.x-3.6 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
3.39 KB

This issue appear on: date, file, grid, select and time components.

I don't know drupal 6, but for D7 the label is output by theme_form_element_label() on includes/form.inc and "for" attribute could be shutdown by unsetting $element['#id']

I would attach a proposed patch for 7.x-3.x-dev

quicksketch’s picture

Status: Needs review » Needs work

Seems like a pretty big hack to me. We could easily just check if the field has any child-elements and automatically determine this property (I think).

robertom’s picture

Status: Needs work » Needs review
FileSize
991 bytes

We could easily just check if the field has any child-elements and automatically determine this property (I think).

Thanks for the hint :)

I've re-rolled patch on dev.

robertom’s picture

quicksketch’s picture

Thanks this looks good to me. Could you confirm that we're not going to accidentally nix the "for" attribute on a field that should have it (like the File component)?

robertom’s picture

Also File component rise validation error:

Error Line 177, Column 35: The for attribute of the label element must refer to a form control.

  <label for="edit-submitted-file">File </label>

this patch remove also this for attribute, but is correct.

The real (and correct) id of file is $element['file']['#id'] and it is "edit-file" instead of "edit-submitted-file".

All other default elements seems correct to me

quicksketch’s picture

Status: Needs review » Needs work
FileSize
811 bytes
1.44 KB

I was looking at this patch and trying to have it make sense for all components and I think this approach may still be a bit heavy-handed. If we can figure out a way to make it work with the File component also (or fix the File component in some other way) we can commit it to the project, but right now this still seems hacky.

Attached are patches with cleaned up documentation and a D6 backport (even though it doesn't do much in D6, since theme_webform_element is not used for form elements).

mgifford’s picture

This looks like a useful addition. What needs to be done to bet it into the next release?

quicksketch’s picture

@mgifford: Since the patch in #13 we completely rewrote the File component, so perhaps that problem no longer applies. We need testing to ensure that the "for" attributes on labels are properly associated with the related element.

mgifford’s picture

Downloaded 7.x-4.0-alpha3 which I assume would have the reworked code. Created a new webform with a date. Grabbed the html output and tossed it into http://validator.w3.org got this error:

Warning Line 200, Column 15: reference to non-existent ID "edit-submitted-date"

today's date

This error can be triggered by:

A non-existent input, select or textarea element
A missing id attribute
A typographical error in the id attribute

Try to check the spelling and case of the id you are referring to.

I also ran it through WAVE, and got a report of an orphan form label. It's looking for an ID of edit-submitted-date but that doesn't exist. There is a day, month, year but no date ID. Therefore there is still a validation issue.

Date is one of the complex form elements that's tied up in #504962: Provide a compound form element with accessible labels

quicksketch’s picture

Downloaded 7.x-4.0-alpha3 which I assume would have the reworked code.

No version has the code applied to it yet.

mgifford’s picture

Ahh, ok, I misunderstood.

I updated the D7 patch to fit with the git repository. That does eliminate the one validation issue.

However, I also uploaded a patch that rather than hacking around to avoid Drupal's fieldset conventions, it just uses it properly. webform_for_attribute-d7-18-correct.patch is semantically better as it does provide a logical grouping and follows best practices like:
http://www.nomensa.com/blog/2010/three-rules-for-creating-accessible-forms/

But ya, it's totally ugly without unique styling and I don't expect to see it in D7 as it would be a new pattern.

mgifford’s picture

Status: Needs work » Needs review

oops, didn't bump the bot.

rooby’s picture

@mgifford:
You are referring to 7.x-4.0-alpha3 but the issue is for 7.x-3.x-dev.

Are the patches for 7.x-3.x-dev?

@quicksketch:

@mgifford: Since the patch in #13 we completely rewrote the File component, so perhaps that problem no longer applies. We need testing to ensure that the "for" attributes on labels are properly associated with the related element.

No version has the code applied to it yet.

So this change is not in any dev versions/git yet? I cannot see any commit messages relating to it.

Any idea when this will be testable?
I am running into file element label validation issues also.

mgifford’s picture

Well, I would assume it was the master branch in git which would probably be closest to 7.x-4.0, but I posted that over a month ago, so really not sure.

rooby’s picture

From memory I think I checked master and it has no commits since december or something.

I have an easy workaround for my use case by overriding theme_form_element_label()

quicksketch’s picture

Version: 7.x-3.x-dev » 7.x-4.x-dev

I think the fieldset approach is an excellent candidate for the 4.x branch, while we're in the business of breaking theming/apis. Considering the effects this would have on existing sites, it probably can't be applied to the 3.x branch.

quicksketch’s picture

Well upon attempting this I found that fieldsets are pretty much a pain to work with because the <legend> tag for fieldsets can't be displayed inline through CSS (as reported throughout the internet). So instead this approach keeps the normal label and displays it exactly as before, but adds a fieldset and a legend that is entirely hidden through CSS. It's completely redundant markup, but something that works. The label is shown (and read through screenreaders going through the page initially), but the legend text is repeated each time focused is changed between elements. It's certainly a usability improvement, but I'm not sure how I feel about it from a code-cleanliness standpoint. I'm sure the designers/themers will lament it... but as far as end-users go (and goverments and organizations that demand accessibility), it's a win. Thoughts?

mgifford’s picture

I wasn't able to apply this to the master branch from git. Were there changes or was this against dev?

The Drupal legacy use of fieldsets is a pain. I'm hoping we can remove it in D8 with - #1168246: Freedom For Fieldsets! Long Live The DETAILS.

Then we can use fieldsets as the W3C requires. Until then the html's going to be a bit messy to deal with accessibility issues properly.

quicksketch’s picture

I wasn't able to apply this to the master branch from git. Were there changes or was this against dev?

There isn't a master branch I don't think. It's against 7.x-4.x.

mgifford’s picture

Ok, it applies perfectly against that repo.. However, I got a PDOException: SQLSTATE[23000] error when working to set up my dev environment so will report that and come back and look at this letter.

quicksketch’s picture

Here's a reroll that applies to the current 4.x branch.

quicksketch’s picture

Status: Needs review » Needs work

Okay, so in my testing this patch does not have adequate results. Yes it makes it so that Webform passes validators, but it has no real impact in my accessibility testing. JAWS and Voiceover won't read the fieldset legends if they're hidden, so this don't help with accessibility for blind users in any real way. Putting this back to needs work.

quicksketch’s picture

I think the only real solution here for accessibility is to do the following:

- Use fieldsets and legends on all components that contain multiple elements (radios, checkboxes, files, date, time, etc).
- Remove the label elements for these components, since they can't point at multiple elements (that's what the legend is for).
- Style the legends to match the appearance of labels as closely as we can in a generic way.
- Unfortunately this means that "inline" label display needs to be removed from these components, because legends simply cannot be displayed inline using CSS and HTML. Legends are very difficult to work with.

quicksketch’s picture

Title: W3C validation gives warning on composed component » W3C validation and accessibility problems from labels pointing at non-existent IDs (grid, date, file, radios, etc.)
mgifford’s picture

This is how I'm hoping to hide the fieldsets in D8 Core [#7980597]

That should address some of the visual changes.

What do you need to help push this along?

mgifford’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +Accessibility

just a re-roll.

mgifford’s picture

I thought i attached it...

mgifford’s picture

The last submitted patch, 13: webform_for_attribute-d7.patch, failed testing.

The last submitted patch, 13: webform_for_attribute-d6.patch, failed testing.

The last submitted patch, 18: webform_for_attribute-d7-18-correct.patch, failed testing.

The last submitted patch, 18: webform_for_attribute-d7-18.patch, failed testing.

The last submitted patch, 24: webform_accessible_multi_elements.patch, failed testing.

The last submitted patch, 28: webform_accessible_multiple_elements-945438-28.patch, failed testing.

joseph.olstad’s picture

Patch from comment #36 applies correctly to commit d12f23225d9bdca8c988a95fddddb6bf61cdb84d of the 7.x-4.x dev branch of webform.

see comments from gdaw below

gdaw’s picture

Testing results for Patch from comment #36

Label now applies to the Input, but describedby does not work.

New error = The aria-describedby attribute must point to an element in the same document.

Ex.

<label for="edit-submitted-keywords">Keywords <span class="form-required" title="This field is required.">* required</span></label>
<input aria-describedby="edit-submitted-keywords--description" type="text" id="edit-submitted-keywords" name="submitted[keywords]" value="" size="60" maxlength="128" class="form-text required" />
DanChadwick’s picture

Status: Needs review » Needs work
mgifford’s picture

@gdaw - does this work properly before the patch is applied? Just looking at the code in the patch:

+  // If there are multiple elements, a label cannot point to all of them.
+  // Removing the ID on the element will remove the label "for" attribute.
+  $multiple_elements = count(element_children($element)) > 1;
+  if ($multiple_elements) {
+    $variables['element']['#id'] = NULL;
+  }

It looks like this would happen in cases where there are multiple elements. I don't have enough information in your case to determine if this is the case or not.

Can you give a bit more context on how to replicate this? The keyword wouldn't be wrapped in a fieldset. Looks like this might be a 2 part problem, where I just fixed one of the issues in my patch above.

joseph.olstad’s picture

Hi MGifford, looks like your patch is working. We debugged a bit more and it looks like the issue we have is comming from our jquery libraries version 1.10.2 .

When we did a search for the string "aria-describedby" it showed up in our jquery files (outside of webforms)
./jquery_update/replace/ui/ui/minified/jquery.ui.tooltip.min.js
./jquery_update/replace/ui/ui/minified/jquery-ui.min.js
./jquery_update/replace/ui/ui/minified/jquery.ui.dialog.min.js
./jquery_update/replace/ui/ui/jquery.ui.tooltip.js
./jquery_update/replace/ui/ui/jquery-ui.js
./jquery_update/replace/ui/ui/jquery.ui.dialog.js

The javascript is placing the aria-describedby= into the tag attributes.

We'll have to re-test in a vanilla drupal environment. Just wondering mgifford , what is your jquery version?

We're moving to bootstrap in the next month or so, I imagine this will change our javascript version and we'll have to retest at that time.

So it's likely that mgiffords patch is good, it resolved the problem of " labels on multiple elements " , our other issue seems to be unrelated to webforms and more to our drupal distro.

mgifford’s picture

It's just with with Core. I didn't upgrade jQuery. Glad that it helped with your label issue Joseph.

DanChadwick’s picture

Status: Needs work » Needs review

What's the status of this? Is #36 RTBC? It looks like #46 may have been a red herring.

DanChadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Component: Miscellaneous » Code
Category: Bug report » Task

I have two related concerns:

  1. Some themes may have CSS which is more specific and causes the new fieldset to have a visual effect or the new legend to actually be displayed.
  2. Some themes may have overly-specific CSS which breaks when the new fieldset is introduced.

Absent further discussion, I'm moving this to D8, where I think #36 would be a good solution.

bond708’s picture

Too bad it didn't make it to 7.x.4 cause this would solve a lot of accessibility issues.

fenstrat’s picture

Status: Needs review » Closed (outdated)

Closing to clear out the old Webform 8.x-4.x branch. See #2827845: [roadmap] YAML Form 8.x-1.x to Webform 8.x-5.x.

Liam Morland’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Closed (outdated) » Active
Liam Morland’s picture

#36 is the same sort of fix as in #2192419: Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes. It would be difficult to do that here without messing up themes. However, the title of this issue is specifically about invalid "for" attributes, which can be fixed.

Liam Morland’s picture

Category: Task » Bug report
Status: Active » Needs review
FileSize
630 bytes

This patch just removes the invalid for attributes.

Status: Needs review » Needs work

The last submitted patch, 57: webform-remove_invalid_for_attr-945438-57-D7.patch, failed testing.

Liam Morland’s picture

Status: Needs work » Needs review
FileSize
670 bytes

Here is another way to do it, directly checking for the existence of the @id. I'm not sure which is better.

Status: Needs review » Needs work

The last submitted patch, 59: webform-remove_invalid_for_attr-945438-59-D7.patch, failed testing.

joseph.olstad’s picture

The CI error appears to be a problem with drupalci_testbot , something is up with it.

failed to open stream: Permission denied in /opt/drupalci_testbot

Liam Morland’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 59: webform-remove_invalid_for_attr-945438-59-D7.patch, failed testing.

Mixologic’s picture

We did a drupalci deployment today, and there were things that didnt go as planned. Sorry. I have requeued the test.

Liam Morland’s picture

Status: Needs work » Needs review

  • Liam Morland committed 20e4d4b on 7.x-4.x
    Issue #945438 by Liam Morland: Prevent label @for from pointing at non-...
Liam Morland’s picture

Title: W3C validation and accessibility problems from labels pointing at non-existent IDs (grid, date, file, radios, etc.) » Prevent label @for from pointing at non-existent @id
Assigned: Unassigned » Liam Morland
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

jenna.tollerson’s picture

Here's a 7.x-3.x version of the patch from #36. Leaving this here just in case someone like me needs it.

ponies’s picture

#69 works for me! Thanks @jenna.tollerson.