1.20.x date.elements.inc date_select_element_process($element, &$form_state, $form)

Flexible date/time drop-down selector.

Splits date into a collection of date and time sub-elements, one for each date part. Each sub-element can be either a textfield or a select, based on the value of ['#date_settings']['text_fields'].

The exact parts displayed in the field are those in #date_granularity. The display of each part comes from ['#date_settings']['format'].

File

modules/date/date.elements.inc, line 522
Date forms and form themes and validation.

Code

function date_select_element_process($element, &$form_state, $form) {
  if (date_hidden_element($element)) {
    return $element;
  }

  $date = NULL;
  if (is_array($element['#default_value'])) {
    $date = date_select_input_date($element, $element['#default_value']);
  }
  elseif (!empty($element['#default_value'])) {
    $date = date_default_date($element);
  }

  $element['#tree'] = TRUE;
  $element['#theme_wrappers'] = array('date_select');
  $element['#attached']['css'][] = backdrop_get_path('module', 'date') . '/css/date.css';
  $element += (array) date_parts_element($element, $date, $element['#date_format']);

  // Store a hidden value for all date parts not in the current display.
  $granularity = date_format_order($element['#date_format']);
  foreach (date_nongranularity($granularity) as $field) {
    if ($field != 'timezone') {
      $element[$field] = array(
        '#type' => 'value',
        '#value' => 0,
      );
    }
  }
  if (isset($element['#element_validate'])) {
    array_push($element['#element_validate'], 'date_select_validate');
  }
  else {
    $element['#element_validate'] = array('date_select_validate');
  }

  $context = array(
    'form' => $form,
  );
  backdrop_alter('date_select_process', $element, $form_state, $context);

  return $element;
}