Hello,

I'm trying to figure out a way to change the label of the date and time how they appear on the node. They only appear as "From Date" and "To Date," and there is no field over time box, and my users won't know to enter the time in that box. Google search only picked up one issue, which actually is the same issue I'm having, but nobody responded to it. That issue is here:

http://drupal.org/node/281112#comment-1108281

I don't mind editing the .module file, but I have looked through the ones that came with the module and I can't seem to find that label anywhere. Can someone point me in the right direction?

Thanks.

Comments

arlinsandbulte’s picture

Version: 5.x-2.3 » 7.x-1.x-dev
Category: support » feature

No, I don't think there is any nice way of doing this.
I'll turn this into a feature request and move it to HEAD.

YK85’s picture

Is there a way of doing this for 6.x by hook form alter or something?
Right now the label is showing as [ -Year ] [ -Month ] [ -Day ] and I would like to change it to [ Year ] [ Month ] [ Day ]
Is there an example of how to do this somewhere?

Thanks!

iLLin’s picture

This is crazy old, but this is how I do things like this.

function mymodule_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'event_node_form':  //content type of form
      $form['field_event_start_date']['#pre_render'] = array('mymodule_date_label');  //field name of the date
      break;
  }
}
/**
 *  Updates date labels on node form.
 */
function mymodule_date_label($element) {
  $element[0]['value']['#title'] = t('Start Date');
  $element[0]['value2']['#title'] = t('End Date');
  return $element;
}

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

Review the api reference and notice the pre_render needs to be an array. I am doing this wrong as if my module was called last and some other module was adding something here, I would reset that array. Just keep that in mind when doing yours.

handsofaten’s picture

Thanks, iLLin. Was having a hell of a time figuring out how to change these values with form alter.

andypost’s picture

If date field will allow to change a labels for From-To so we should decide on translation.
Once label is entered so It's a user text which does not translates with locale module

Naiya’s picture

Thanks iLLin. i wanted to change it everywhere, so i added

$form['date_filter']['min']['#title'] = t('From');

to my form_alter.

karens’s picture

Status: Active » Fixed

I added theme functions for the date and time labels, similar to the theme functions for the year, month, day, etc labels in the select widget. Now you can override theme_date_part_label_date() and theme_date_part_label_time().

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alsator’s picture

Component: Date CCK Field » Code
Issue summary: View changes

The following example shows the way to change 'Year' label of selectbox of date field.

function {module_name}_date_combo_process_alter(&$element, &$form_state, &$context) {
	
  if($element['#field_name'] == '{field_name}') {		
    $element['#pre_render'][] = '_year_labels_alter';
  }
}



function _year_labels_alter($element) {
	
  $element['value']['#pre_render'][] = '_start_year_label_alter';
  $element['value2']['#pre_render'][] = '_end_year_label_alter';
	
  return $element;
}



function _start_year_label_alter($element) {
	
  $element['year']['#title'] = t('Start Year');
	
  return $element;
}



function _end_year_label_alter($element) {
	
	$element['year']['#title'] = t('End Year');
	
	return $element;
}