4.7.x form.inc theme_date($element)
5.x form.inc theme_date($element)
6.x form.inc theme_date($element)
7.x form.inc theme_date($variables)

Returns HTML for a date selection form element.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes.

Related topics

1 theme call to theme_date()
system_element_info in modules/system/system.module
Implements hook_element_info().

File

includes/form.inc, line 3064
Functions for form and batch generation and processing.

Code

function theme_date($variables) {
  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] = (array) $element['#attributes']['class'];
  }
  $attributes['class'][] = 'container-inline';
  return '<div' . drupal_attributes($attributes) . '>' . drupal_render_children($element) . '</div>';
}

Comments

hgneng’s picture

The default date format does not conform to Chinese's convention. In Chinese, "year" comes first. There is a character "年" after year number and a "日" after day number.

My solution to fix this is that adding following function in theme template.php file:

function zenone_date($variables) {
  $variables['element']['year']['#weight'] = -0.001;
  $variables['element']['month']['#weight'] = 0;
  $variables['element']['day']['#weight'] = 0.001;
  $variables['element']['#sorted'] = FALSE;

  foreach ($variables['element']['year']['#options'] as &$value) {
    $value .= '年';
  }

  foreach ($variables['element']['day']['#options'] as &$value) {
    $value .= '日';
  }

  return theme_date($variables);
}
Romisha’s picture

Thank you very much. This is exactly what I wanted.