1 date.elements.inc date_popup_element_process($element, &$form_state, $form)

Javascript popup element processing.

Add popup attributes to $element.

File

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

Code

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

  module_load_include('inc', 'date', 'date.elements');

  $element['#tree'] = TRUE;
  $element['#theme_wrappers'] = array('date_popup');
  $element['#attached']['library'][] = array('date_popup', 'date_popup');

  if (!empty($element['#ajax'])) {
    $element['#ajax'] += array(
      'trigger_as' => array(
        'name' => $element['#name'],
      ),
      'event' => 'change',
    );
  }

  $element['date'] = _date_popup_process_date_part($element);
  $element['time'] = _date_popup_process_time_part($element);

  // If
  if (empty($element['#date_title_printed'])) {
    // Both date and time exist.
    if (!empty($element['date']) && !empty($element['time'])) {
      $element['date']['#title'] = $element['#title'];
      $element['date']['#title_display'] = $element['#title_display'];
      $element['date']['#required'] = $element['#required'];
    }
    // Only date exists.
    elseif (!empty($element['date']) && empty($element['time'])) {
      $element['date']['#title'] = $element['#title'];
      $element['date']['#title_display'] = $element['#title_display'];
      $element['date']['#required'] = $element['#required'];
    }
    // Only time exists.
    elseif (empty($element['date']) && !empty($element['time'])) {
      $element['time']['#title'] = $element['#title'];
      $element['time']['#title_display'] = $element['#title_display'];
      $element['time']['#required'] = $element['#required'];
    }

  }

  // Remove the title from the overall element.
  $element['#title'] = NULL;

  if (isset($element['#element_validate'])) {
    array_push($element['#element_validate'], 'date_popup_validate');
  }
  else {
    $element['#element_validate'] = array('date_popup_validate');
  }

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

  return $element;
}