You are here

function date_text_element_process in Date 7

Same name and namespace in other branches
  1. 7.3 date_api/date_api_elements.inc \date_text_element_process()
  2. 7.2 date_api/date_api_elements.inc \date_text_element_process()

Text date input form.

Display all or part of a date in a single textfield.

The exact parts displayed in the field are those in #date_granularity. The display of each part comes from #date_format.

1 string reference to 'date_text_element_process'
_date_api_element_info in date_api/date_api_elements.inc
Implementation of hook_element_info().

File

date_api/date_api_elements.inc, line 213
Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.

Code

function date_text_element_process($element, $form_state, $form) {
  $element['#tree'] = TRUE;
  $element['#theme_wrappers'] = array(
    'date_text',
  );
  $element['date']['#value'] = $element['#value']['date'];
  $element['date']['#type'] = 'textfield';
  $element['date']['#weight'] = !empty($element['date']['#weight']) ? $element['date']['#weight'] : $element['#weight'];
  $element['date']['#attributes'] = array(
    'class' => isset($element['#attributes']['class']) ? $element['#attributes']['class'] += array(
      'date-date',
    ) : array(
      'date-date',
    ),
  );
  $element['date']['#description'] = ' ' . t('Format: @date', array(
    '@date' => date_now()
      ->format($element['#date_format']),
  ));

  // Keep the system from creating an error message for the sub-element.
  // We'll set our own message on the parent element.

  //$element['date']['#required'] = $element['#required'];
  $element['date']['#theme'] = 'date_textfield_element';
  if (isset($element['#element_validate'])) {
    array_push($element['#element_validate'], 'date_text_validate');
  }
  else {
    $element['#element_validate'] = array(
      'date_text_validate',
    );
  }
  if (!empty($element['#force_value'])) {
    $element['date']['#value'] = $element['date']['#default_value'];
  }
  return $element;
}