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.
I have several forms that requires different names for start and end dates. Current date field uses the same label for both: Date.
How can I change it via date_combo_process_alter? I'm not sure how to alter the label when using the popup calendar widget. The code below does not works, only the portion to remove the inline "to".
function mycustomwebform_date_combo_process_alter(&$element, &$form_state, &$context) {
if ($element['#field_name'] == 'field_my_custom_dates') {
$element['value']['#date_title'] = 'From';
$element['value2']['#date_title'] = 'To';
$element['value2']['#title'] = t('');
}
}
Comments
Comment #1
luthien CreditAttribution: luthien commentedComment #2
dgroene CreditAttribution: dgroene commentedNo variable you change is going to alter the label because the word 'Date' is hard-coded in the theme function:
function theme_date_part_label_date($variables) {
return t('Date', array(), array('context' => 'datetime'));
}
To change the label, you need to override theme_date_part_label_dates.