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:

CommentFileSizeAuthor
#13 label.patch_0.txt1.33 KBZen
#11 label.patch.txt836 bytesZen
#3 _47544_ids.patch1.86 KBMorbus Iff
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Morbus Iff’s picture

This 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.

Morbus Iff’s picture

Component: search.module » forms system
Morbus Iff’s picture

Title: search/node does not validate » Element #name, not #id, were being passed to theme_form_element
FileSize
1.86 KB

Patch 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).

Morbus Iff’s picture

Status: Active » Needs review
Morbus Iff’s picture

Alright - 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.

Zen’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Zen’s picture

Status: Fixed » Active

Keeping this active as this has only been partially fixed.

Thanks
-K

Wesley Tanaka’s picture

Title: Element #name, not #id, were being passed to theme_form_element » search/node does not validate
Morbus Iff’s picture

Title: search/node does not validate » Checkboxes, radios, and improper use of LABELs.
Zen’s picture

Status: Active » Needs review
FileSize
836 bytes

Attached 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

Zen’s picture

Forgot 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

Zen’s picture

FileSize
1.33 KB
chx’s picture

Status: Needs review » Reviewed & tested by the community

for = idref [CS]
This attribute explicitly associates the label being defined with another control. When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document. When absent, the label being defined is associated with the element's contents.

http://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.

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

applied

Anonymous’s picture

Status: Fixed » Closed (fixed)