Greetings,

It is impossible to customize HTML (styles) for select components because theme_select($element) function calls form_select_options() function which is impossible to overload.

form_select_options() function has HTML hardcoded inside (such as and ).

We are using taxonomy and need to change style for parent items (those items are options and should not be implemented as option group because it is disabled). We have to rewrite the whole theme_select($element) function.

If you are not going to change form_select_options() function at least add parent class for parent select items please.

Thank you.

Comments

Pasqualle’s picture

Version: 6.x-dev » 7.x-dev
Category: feature » bug

this is a bug, because HTML is not allowed outside the theme functions.

Wim Leers’s picture

Category: bug » feature

IMO it's not a bug. It's a helper function for a theme function. If you'd say it should be merged with the theme function, you'd be wrong, because this is actually a *recursive* function. You can't include that in the theme function that calls it.

Also, you *can* override it. Just override theme_select() and then *don't* use form_select_options(). Easy enough :)

What you could argue, is that you should be able to set attributes for options. I think that's what you're trying to say with "at least add parent class for parent select items please".

Wim Leers’s picture

Status: Active » Closed (fixed)
andypost’s picture

Category: feature » bug
Status: Closed (fixed) » Needs work

This actually should be fixed. Maybe in D8

This is a bug because
1) optgroup doesn't do hierarchy - so using this function with recursion is broken http://www.w3.org/TR/html401/interact/forms.html#h-17.6
2) option could contain attributes (disabled, label and class)

andypost’s picture