According to the Forms API Reference, all form elements have an #attributes property that can be used to add any applicable html attributes to the form item. Select does not have that currently -- it only has #extra, which simply adds the contents of #extra rather than using the drupal_attributes function. Here is a patch that remedies this problem.

Please review it and apply.

CommentFileSizeAuthor
select_attributes.patch1.2 KBvhmauery

Comments

tangent’s picture

A quick look at the docs reveals that the select item should have an attributes field and has no mention of the extras field. Makes sense.

I don't have time to test this patch though.

vhmauery’s picture

FWIW, I tested it while rewriting the form code for Acidfree. It seemed to work fine for me there.

vhmauery’s picture

Status: Needs review » Closed (fixed)

It looks like this has been fixed, so I guess I will close this.