This patch moves to using an unordered list of checkboxes or radios since that is a bit more meaningful than a bunch of divs. It removes the extra whitespace. And it puts the input element outside of the label.

CommentFileSizeAuthor
#3 drupal_44.patch5.45 KBm3avrck
form_0.patch5.28 KBdrumm

Comments

factoryjoe’s picture

+1

ixis.dylan’s picture

I like it.

m3avrck’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new5.45 KB

Great patch Neil!

I rerolled this patch against HEAD and also added 2 new classes, form-radios and form-checkboxes. That way themers can style these differently (or in most cases, adjust margins/padding, generally on checkboxes).

Also, because of the changes in the patch, the CSS in the above patch was wrong, it still displayed the list-style-type. I corrected the CSS and also corrected the margins so it displays correctly against all major browsers (above patch's CSS created huge margins in IE).

Should be good to go now!

dries’s picture

Status: Reviewed & tested by the community » Needs work

No longer applies. Does this degrate more or less OK in absence of CSS?

m3avrck’s picture

Status: Needs work » Reviewed & tested by the community

Dries, my above patch still applies cleanly against HEAD.

As for the CSS, yes it degrades very nicely. With CSS disabled, you see a list of checkboxes or radios, appearing almost nearly as identical with CSS turned on.

dries’s picture

I tried and it looks really weird in absence of CSS.

$ find . -name *.css | xargs rm
drumm’s picture

Yes, the bullet points are a bit weird. These are lists, so I think it is okay for the small portion of people without CSS.

Crell’s picture

Any CSS-base design looks like ass without CSS enabled, including drupal.org. :-) The question is whether it is still functional. An unordered list of checkboxes may be ugly, but it's still semantically correct and visually understandable. It's actually more correct than a bunch of divs, I'd argue.

m3avrck’s picture

I agree with said comments.

In absensce of CSS of you are literrally "turning off style" of course it is not going to look that good :-) But, it is *much* more semantically correct, which to accessibility and screen readers and Google, is *much* more meaningful and much more useful. DIVs are overused, use semenatic content when available.

Still RTC :-)

drumm’s picture

A lot of tables in core misuse form_checkboxes and form_radios to generate individual checkboxes. This generates an <li> without a <ul>.

I think the way to this is to only use single checkboxes and radio buttons in forms. I might get a chance to do this in a separate issue.

drumm’s picture

Status: Reviewed & tested by the community » Needs work
Jaza’s picture

Version: x.y.z » 6.x-dev

Moving to 6.x-dev queue.

pancho’s picture

Title: Less whitespace in radios checkboxes form elements » Semantically correct radios and checkboxes
Version: 6.x-dev » 7.x-dev

Doing this without breaking stuff obviously is too tricky to it done get that late in dev cycle. Have to bump it to D7. :(

mgifford’s picture

Well, this seems like a good idea. Patch doesn't apply at all well against the CVS at the moment. Wanted to flag this before we get too late in the end of the D7 dev cycle.

mgifford’s picture

Issue tags: +Accessibility

Adding accessibility tag

mgifford’s picture

I do want to give this more thought, but it seems that much of this patch has already been applied.

Main issues are to make lists of radio & checkboxes semantically correct by making sure that they are in an unordered list.

Adding

    is probably just something that could be swapped for

    (with some modifications of course) in the function theme_radios(). That would be pretty simple I think.

    But think it's going to need a serious hack to http://api.drupal.org/api/function/drupal_process_form/7 to allow the list items to be displayed. Really not sure how to pass that it is a list along to the part of the form builder that actually creates the html.

    And of course there's:

    +ul.form-radios, ul.form-checkboxes {
    + margin: 0.5em 0 0 0;
    + padding: 0;
    + list-style-type: none;
    +}

    Everett Zufelt’s picture

    I can see the semantic advantage of having a list of radio or checkbox elements marked up as part of a list. I don't believe that this would actually mean any appreciable advantage for users of assistive technology. I also see the problem of theming radio and checkbox elements with an li wrapper if that same element may be displayed in a table cell.

    One possible method of working around this would be to only theme radio and checkbox elements as list items if their parent element is radios or checkboxes. We could also possibly create a new property for the radios and checkboxes form element types that will allow form developers to select whether the collection will be themed as a list or not.

    mgifford’s picture

    Issue tags: -Accessibility

    I'm going to drop the accessibility tag here as Everett didn't see this as a major advantage to assistive tech users.

    Also going to point folks to #558928: Form element labeling is inconsistent, inflexible and bad for accessibility as surely if we had more consistent forms we'd have less inconsistent results (like the ones described above).

    Everett Zufelt’s picture

    Version: 7.x-dev » 8.x-dev

    Tempted to close this issue, I don't really see the advantage. But, since others have seen the advantage in the past bumping to D8.

    Everett Zufelt’s picture

    Status: Needs work » Closed (won't fix)

    I have to say that I still don't see a use-case. No comment in 10 months and a 5 year old issue.