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
Comment #1
Pasquallethis is a bug, because HTML is not allowed outside the theme functions.
Comment #2
Wim LeersIMO 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* useform_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".
Comment #3
Wim LeersComment #4
andypostThis 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)
Comment #5
andypostDuplicate of #284917: Allow FAPI select, radios, and checkboxes to specify some options as disabled