Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
search/node on my site does not seem to validate as XHTML 1.0
transitional.
The errors I get from the w3c validator are:
Line 183, column 22: character "[" is not allowed in the value of attribute "for"
Only of the type:
Line 183, column 13: reference to non-existent ID "edit-edit[type]"
Only of the type:
Comment | File | Size | Author |
---|---|---|---|
#13 | label.patch_0.txt | 1.33 KB | Zen |
#11 | label.patch.txt | 836 bytes | Zen |
#3 | _47544_ids.patch | 1.86 KB | Morbus Iff |
Comments
Comment #1
Morbus IffThis appears to happen for any set of checkboxes (not radio buttons) - see also the "Default options" under a node type in admin/settings/content-types. The "for" of a LABEL is actually determined by theme_form_element, which is called by the corresponding theme_FORMTYPE - so theme_radios, theme_checkboxes, and so forth. theme_radios and, in fact, most other theme_FORMTYPE functions, pass either $element['#name'] or $element['#id'] to form_element - theme_checkboxes, however, passes "edit-" . $element['#name'], which is part of our problem. I think the right thing to pass is JUST $element['#id']. I'll do some testing in a few hours.
Comment #2
Morbus IffComment #3
Morbus IffPatch attached.
Unfortunately, although the patch needs to be committed, regardless of your validation problem, it doesn't actually entirely solve the validation problem, since now it'll complain "reference to non-existent ID "edit-type"" (which refers to the label of a set of checkboxes, which themselves get names like edit-type-story).
Comment #4
Morbus IffComment #5
Morbus IffAlright - the above patch needs a review. It should be committed.
The larger issue is that we're creating LABELs for groups of checkboxes and radios, when we shouldn't be. To really fix wtanaka's original problem, theme_checkboxes and theme_radios need to stop relying on theme_form_element, somehow.
Comment #6
Zen CreditAttribution: Zen commentedTested and working fine. As Morbus said, this patch doesn't address the primary issue where no element exists with the ID indicated by the for attribute. But, this patch can be committed in the meantime..
+1
-K
Comment #7
Dries CreditAttribution: Dries commentedCommitted to HEAD. Thanks.
Comment #8
Zen CreditAttribution: Zen commentedKeeping this active as this has only been partially fixed.
Thanks
-K
Comment #9
Wesley Tanaka CreditAttribution: Wesley Tanaka commentedComment #10
Morbus IffComment #11
Zen CreditAttribution: Zen commentedAttached patch is a slightly ugly fix to get the checkboxes element to validate. Ideally, we would want the label gone entirely, but this might require a larger change to theme_form_element or some such. IMO it is best to leave that for post 4.7.
Thanks,
-K
Comment #12
Zen CreditAttribution: Zen commentedForgot to explain:
The above patch removes the 'for' attribute from the label tag thereby facilitating a successful validation. This is however still sub-optimal, as (AFAIK) a label element has to be associated with a (and only one) form element.
Thanks
-K
Comment #13
Zen CreditAttribution: Zen commentedComment #14
chx CreditAttribution: chx commentedhttp://www.w3.org/TR/html4/interact/forms.html#h-17.9.1
and while I was unable to find this for XHTML, the only restriction for label there is that it can't contain another label. Well it doesn't. So we are good to go.
Comment #15
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedapplied
Comment #16
(not verified) CreditAttribution: commented