You are here

public function DatePopupTimepickerTimepicker::processElement in Date Popup Timepicker 7

Element process callback.

Parameters

array $element: Form API element structure to process.

array $form_state: Form state.

array $form: The whole form definition structure.

Return value

array Processed form element.

Overrides DatePopupTimepicker::processElement

File

plugins/timepicker/timepicker.inc, line 144

Class

DatePopupTimepickerTimepicker
Class DatePopupTimepickerTimepicker.

Code

public function processElement(array $element, array &$form_state, array $form) {
  $granularity = date_popup_time_granularity($element);
  $options_default = array(
    'showHours' => in_array('hour', $granularity),
    'showMinutes' => in_array('minute', $granularity),
  );
  $element['#timepicker_options'] = array_replace_recursive($options_default, $element['#timepicker_options']);
  $element['#attached']['library'][] = array(
    'system',
    'ui.core',
  );
  $element['#attached']['library'][] = array(
    'system',
    'ui.widget',
  );

  // Add Timepicker library.
  $element['#attached']['libraries_load'][] = array(
    'timepicker',
  );

  // @todo is it the best place for plugin specific .js?
  $element['#attached']['js'][] = drupal_get_path('module', 'date_popup_timepicker') . "/js/date_popup_timepicker.timepicker.js";
  return $element;
}