Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In a theme you need to add css classes to the form element and add this code:
function foo_preprocess_webform_date(&$variables) {
$variables['element']['year']['#attributes']['class'][] = 'foo-inline';
$variables['element']['month']['#attributes']['class'][] = 'foo-inline';
$variables['element']['day']['#attributes']['class'][] = 'foo-inline';
}
and this is just ignored because of:
/**
* Theme a webform date element.
*/
function theme_webform_date($variables) {
$element = $variables['element'];
$element['year']['#attributes']['class'] = array('year');
$element['month']['#attributes']['class'] = array('month');
$element['day']['#attributes']['class'] = array('day');
This code need to be changed to:
/**
* Theme a webform date element.
*/
function theme_webform_date($variables) {
$element = $variables['element'];
$element['year']['#attributes']['class'][] = 'year';
$element['month']['#attributes']['class'][] = 'month';
$element['day']['#attributes']['class'][] = 'day';
Comment | File | Size | Author |
---|---|---|---|
#6 | Issue-2030869-by-hass-Theme-cannot-add-classes-via-p.patch | 939 bytes | hass |
#2 | Issue-2030869-by-hass-Theme-cannot-add-classes-via-p.patch | 975 bytes | hass |
Comments
Comment #1
hass CreditAttribution: hass commentedAside naming a class just "day" or month MUST cause collisions. These classes should be prefixed with the module name.
Comment #2
hass CreditAttribution: hass commentedComment #3
hass CreditAttribution: hass commentedv3.19 was the start version
Comment #4
quicksketchThanks, I'll put this in next time I'm committing patches.
Comment #5
quicksketchHm, actually I'm not sure about changing the class. We can't do that in the 3.x branch because it may break existing sites that used the previous markup.
Comment #6
hass CreditAttribution: hass commentedPatch without class name changes.
Comment #7
quicksketchThanks!
Comment #8
hass CreditAttribution: hass commentedNeeds to go into 4.x, too.
Comment #9
quicksketchPushed to 7.x-3.x and 7.x-4.x.