Same as #2030869: Theme cannot add classes via preprocess webform date
Theme code
/**
* Implements theme_preprocess_webform_time().
*/
function foo_preprocess_webform_time(&$variables) {
// #2030885: Theme cannot add classes via theme_preprocess_webform_time().
$variables['element']['hour']['#attributes']['class'][] = 'foo-inline';
$variables['element']['minute']['#attributes']['class'][] = 'foo-inline';
$variables['element']['ampm']['#attributes']['class'][] = 'foo-inline';
Broken code:
/**
* Theme a webform time element.
*/
function theme_webform_time($variables) {
$element = $variables['element'];
$element['hour']['#attributes']['class'] = array('hour');
$element['minute']['#attributes']['class'] = array('minute');
Bugfix:
/**
* Theme a webform time element.
*/
function theme_webform_time($variables) {
$element = $variables['element'];
$element['hour']['#attributes']['class'][] = 'hour';
$element['minute']['#attributes']['class'][] = 'minute';
Comments
Comment #0.0
hass commenteda
Comment #1
hass commentedComment #2
hass commentedComment #3
hass commentedv3.19 was the start version
Comment #4
quicksketchSame as #2030869: Theme cannot add classes via preprocess webform date, I'm not sure we should change the class on these elements because it may break the CSS of existing sites. We can change the class in the 4.x branch if we desire, but I'm not sure if "form-select-hour" is really a necessity. You can already target the element accurately by using select.hour as the selector, which seems contextually like the "right" way to name your classes.
Comment #5
hass commentedPatch without class name changes.
Comment #6
hass commentedPlease see #2029187: [meta] Make sure CSS classes are prefixed properly about such bad class names. All these class names should be prefixed with the module name to prevent theme classes. I'm fine with changing this in 4.x
Comment #7
hass commentedNeeds to go into 4.x, too.
Comment #8
quicksketchPushed to 7.x-3.x and 7.x-4.x. No ability to backport to 6.x-3.x since D6 uses strings for classes.
Comment #9
quicksketchComment #10.0
(not verified) commenteda