Webform should provide it's own theme functions for ALL form elements. Some form elements already have their own theming (like the grid component), but this should be extended to all form elements.

Some benefits we can get by making our own theme function to replace theme_form_element():
- Put the "required" asterisk on elements that are required, while providing our own validation so that the "Previous" button can be used without throwing validation errors. (#266287: mandatory components interfere with previous page button )
- Allow labels to be displayed inline or above the field. (#255356: Option for putting label and field on same line (inline))
- Put the "required" asterisk on required file fields without breaking uploads. (#277236: Required File Upload fields don't have asterisks (*))

Comments

quicksketch’s picture

Status: Active » Closed (duplicate)

Well, turns out this is next to impossible to accomplish. We can't have a general "theme_webform_element()" function to replace "theme_form_element" because it'd require overriding every existing type, such as theme_radios(), theme_checkboxes(), theme_select(), theme_textfield(), theme_textarea(), etc. Worse than that it is (literally) impossible to put a different #theme property on radios and checkboxes. The presence of a #theme property causes FAPI to render the element in a different order, and ends up "double-wrapping" the element in theme_form_element() despite whatever the #theme property is.

The only way around this would be to create our own #type = 'webform_checkboxes' or something similar, but really this has just gone too far down the rabbit hole to be worth pursuing, at least in Drupal 6. The calling order of theme functions has been fixed in D7, hopefully making this possible without having to override every single form element type.

Ludo.R’s picture

Version: » 6.x-3.4
Status: Closed (duplicate) » Active

Hi,

I'm trying to override theme_webform_element() function in my theme (Webform 6.x-3.4).
It seems the module doesnt use this function, modifying the function has no effect.

Can you confirm that?

Is there another option to theme elements?

quicksketch’s picture

Status: Active » Closed (duplicate)

The theme_webform_element() element is only used when viewing submissions, not when filling out the form. This is because the Form API in Drupal 6 is impossible to override. theme_webform_element() is used both when viewing submissions and filling out new ones.

I'm putting this back to the previous state. As noted in the submission guidelines, I don't provide support on theming or custom coding.