You are here

public function DatePopupTimepickerTimepicker::fieldSettingsForm in Date Popup Timepicker 7

Define field settings form.

All exposed settings should be contained by "timepicker_options" element. Helper elements may be defined outside of "timepicker_options".

Parameters

array $form: Settings form definition.

array $context: Array containing 3 elements: "field info", "instance info" and "has_data" flag.

array $settings: Currently saved settings in the field.

Return value

array Timepicker settings form part definition.

Overrides DatePopupTimepicker::fieldSettingsForm

File

plugins/timepicker/timepicker.inc, line 204

Class

DatePopupTimepickerTimepicker
Class DatePopupTimepickerTimepicker.

Code

public function fieldSettingsForm(array $form, array $context, array $settings = array()) {
  $element = array();
  $defaults = $this
    ->settingsDefaults();
  $options = isset($settings['timepicker_options']) ? $settings['timepicker_options'] : array();
  $options = array_replace_recursive($defaults, $options);
  $element['showLeadingZero'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show hours leading zero'),
    '#description' => t('Define whether or not to show a leading zero for hours < 10.'),
    '#default_value' => $options['showLeadingZero'],
  );
  $element['showPeriodLabels'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show period labels'),
    '#description' => t('Define if the AM/PM labels on the left are displayed.'),
    '#default_value' => $options['showPeriodLabels'],
  );

  // Define an alternate input to parse selected time to
  // $form['altField'] = array();
  // @todo Use date_popup element.
  $element['timepickerType'] = array(
    '#title' => t('Choose how to render the timepicker'),
    '#type' => 'radios',
    '#options' => array(
      'popup' => t('Popup'),
      'inline' => t('Inline'),
    ),
    '#default_value' => $options['timepickerType'],
  );
  $element['defaultTime'] = array(
    '#type' => 'textfield',
    '#title' => t('Default time'),
    '#description' => t("Used as default time when input field is empty or for inline timePicker. Set to 'now' for the current time, '' for no highlighted time."),
    '#default_value' => $options['defaultTime'],
  );
  $element['showOn'] = array(
    '#type' => 'select',
    '#title' => t('Show on'),
    '#description' => t("Define when the timepicker is shown."),
    '#options' => array(
      'focus' => t('Focus'),
      'button' => t('Button'),
      'both' => t('Both'),
      'none' => t('None'),
    ),
    '#default_value' => $options['showOn'],
  );

  // jQuery selector that acts as button trigger. ex: '#trigger_button'
  // $element['button'] = array();
  $element['hourText'] = array(
    '#type' => 'textfield',
    '#title' => t('Hour text'),
    '#default_value' => $options['hourText'],
  );
  $element['minuteText'] = array(
    '#type' => 'textfield',
    '#title' => t('Minute text'),
    '#default_value' => $options['minuteText'],
  );

  // Corner of the dialog to position,
  // used with the jQuery UI Position utility if present.
  // $element['myPosition'] = array();
  // Corner of the input to position
  // $element['atPosition'] = array();
  $element['hours'] = array(
    '#type' => 'fieldset',
    '#title' => t('Hours'),
    '#collapsible' => FALSE,
    'starts' => array(
      '#type' => 'textfield',
      '#title' => t('Starts'),
      '#description' => t('First displayed hour.'),
      '#default_value' => $options['hours']['starts'],
    ),
    'ends' => array(
      '#type' => 'textfield',
      '#title' => t('Ends'),
      '#description' => t('Last displayed hour.'),
      '#default_value' => $options['hours']['ends'],
    ),
  );
  $element['minutes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Minutes'),
    '#collapsible' => FALSE,
    'starts' => array(
      '#type' => 'textfield',
      '#title' => t('Starts'),
      '#description' => t('First displayed minute.'),
      '#default_value' => $options['minutes']['starts'],
    ),
    'ends' => array(
      '#type' => 'textfield',
      '#title' => t('Ends'),
      '#description' => t('Last displayed minute.'),
      '#default_value' => $options['minutes']['ends'],
    ),
    'interval' => array(
      '#type' => 'textfield',
      '#title' => t('Interval'),
      '#description' => t('Interval of displayed minutes.'),
      '#default_value' => $options['minutes']['interval'],
    ),
  );
  $element['rows'] = array(
    '#type' => 'textfield',
    '#title' => t('Rows'),
    '#description' => t('Number of rows for the input tables, minimum 2, makes more sense if you use multiple of 2.'),
    '#default_value' => $options['rows'],
  );
  $element['minTime'] = array(
    '#type' => 'fieldset',
    '#title' => t('Min time'),
    '#description' => t('Set the minimum time selectable by the user, disable hours and minutes previous to min time.'),
    '#collapsible' => FALSE,
    'hour' => array(
      '#type' => 'textfield',
      '#title' => t('Min hour'),
      '#default_value' => $options['minTime']['hour'],
    ),
    'minute' => array(
      '#type' => 'textfield',
      '#title' => t('Min minute'),
      '#default_value' => $options['minTime']['minute'],
    ),
  );
  $element['maxTime'] = array(
    '#type' => 'fieldset',
    '#title' => t('Max time'),
    '#description' => t('Set the minimum time selectable by the user, disable hours and minutes after max time.'),
    '#collapsible' => FALSE,
    'hour' => array(
      '#type' => 'textfield',
      '#title' => t('Max hour'),
      '#default_value' => $options['maxTime']['hour'],
    ),
    'minute' => array(
      '#type' => 'textfield',
      '#title' => t('Max minute'),
      '#default_value' => $options['maxTime']['minute'],
    ),
  );
  $element['showCloseButton'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show close button'),
    '#description' => t('Shows an OK button to confirm the edit.'),
    '#default_value' => $options['showCloseButton'],
  );
  $element['closeButtonText'] = array(
    '#type' => 'textfield',
    '#title' => t('Close button text'),
    '#description' => t('Text for the confirmation button (ok button).'),
    '#default_value' => $options['closeButtonText'],
  );
  $element['showNowButton'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show now button'),
    '#description' => t('Shows the "now" button.'),
    '#default_value' => $options['showNowButton'],
  );
  $element['nowButtonText'] = array(
    '#type' => 'textfield',
    '#title' => t('Now button text'),
    '#description' => t('Text for the now button.'),
    '#default_value' => $options['nowButtonText'],
  );
  $element['showDeselectButton'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show deselect button'),
    '#description' => t('Shows the deselect time button.'),
    '#default_value' => $options['showDeselectButton'],
  );
  $element['deselectButtonText'] = array(
    '#type' => 'textfield',
    '#title' => t('Deselect button text'),
    '#description' => t('Text for the deselect button.'),
    '#default_value' => $options['deselectButtonText'],
  );
  return array(
    // There is no need to define #tree => TRUE.
    'timepicker_options' => $element,
  );
}