This relates to WCAG
Guideline 1.3: Ensure that information and structure can be separated from presentation
Success Criterion 1.3.1: Information and relationships conveyed through presentation can be programmatically determined, and notification of changes to these is available to user agents, including assistive technologies. (Level A)
Technique H71: Providing a description for groups of form controls using fieldset and legend elements

Basically when multiple form elements with the same "name" attribute are displayed one below the other, they should be wrapped in a <fieldset>, with a <legend>. Attached image shows the problem detected by Wave toolbar.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MiroslavBanov’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +wcag2
FileSize
820 bytes

Updated issue description. Added links to WCAG 2 requirements.

Attached a patch that is my first attempt at solving the problem. The patch wraps the checkboxes/options in an extra fieldset, also removes the <label> element, instead adds the a <legend> to the <fieldset>. This also solves the problem with Orphaned form label - Label pointing to non-existing form element.

Status: Needs review » Needs work

The last submitted patch, 1: wrap_in_fieldset-2210313-1.patch, failed testing.

MiroslavBanov’s picture

I guess the tests would need to be heavily rewritten to make this pass with the changed render array structure. Other option is to have some theme wrapper that wraps the existing form element in a fieldset without actually adding a new render array element.

DanChadwick’s picture

This would seem to be a rather large visual change. I'm wondering whether it is okay to "spring" this on existing users, even with some sort of notice.

It would be ugly, but the option to render within a fieldset could be exposed to the user, perhaps with false set for existing webforms (in an update routine) and true for new webforms (as the default).

mgifford’s picture

This looks like a good accessibility improvement!

This is how we've dealt with the visual side of this in D8 #2002336: Introduce a CSS class to hide borders of fieldset elements

DanChadwick’s picture

Is it appropriate to address a system-wide issue of using invisible fieldsets to group radio/checkboxes in webforms? Maybe #2002336: Introduce a CSS class to hide borders of fieldset elements should be backported to drupal 7.x?

mgifford’s picture

Fieldsets are used inappropriately in D7 to provide collapsible elements of a page. This is broken out in D8 so that we are using HTML5 <details> to provide this role.

Backporting this would be difficult.

Although perhpas the CSS would be easier...

 /**
+ * Unboxed fieldsets for grouping form elements.
+ */
+.fieldgroup {
+  border-width: 0;
+  padding: 0;
+}
quicksketch’s picture

Status: Needs work » Closed (duplicate)

This issue is a duplicate of #1147994: Wrap composite elements in a fieldset element. Could you reupload your patch and suggested changes over there? At this point, I think we'd only be able to make this change to 7.x-4.x, considering wrapping a new fieldset could break a significant amount of existing theming.

MiroslavBanov’s picture

The duplicated issue is named "Accessibility Issue with Select Elements: Form Label Not Associated With Input". I think it should at least be renamed if this one is truly duplicate of it. It is very confusing to me at this point.

If anyone is interested in moving patches and information around or developing a solution for 7.x-4.x, you are very welcome. I won't be able to help in that for some time.

ddod’s picture

Patch #1 applies cleanly on 4.9.
The patch from the duplicate issue also fixes the problem and should be the one used.
https://www.drupal.org/node/1147994#comment-10072560

mgifford’s picture

Issue tags: -wcag2