You are here

public function DatePopupTimepickerTimepicker::fieldSettingsFormSubmit in Date Popup Timepicker 7

Field Settings Form submit callback.

Parameters

array $element: Field settings form element/part as defined in the fieldSettingsForm().

array $values: Submitted settings values for defined settings form element/part.

array $form: Whole settings form basically defined by field_ui_field_edit_form().

array $form_state: Whole form state passed to field_ui_field_edit_form_submit() and other submit callbacks of the field_ui_field_edit_form form.

Overrides DatePopupTimepicker::fieldSettingsFormSubmit

See also

field_ui_field_edit_form()

field_ui_field_edit_form_submit()

File

plugins/timepicker/timepicker.inc, line 644

Class

DatePopupTimepickerTimepicker
Class DatePopupTimepickerTimepicker.

Code

public function fieldSettingsFormSubmit(array &$element, array &$values, array &$form, array &$form_state) {
  $new = $values['timepicker_options'];

  // Convert boolean settings to boolean.
  $boolean = array(
    'showLeadingZero',
    'showPeriodLabels',
    'showCloseButton',
    'showNowButton',
    'showDeselectButton',
  );
  foreach ($boolean as $key) {
    $new[$key] = (bool) $values['timepicker_options'][$key];
  }

  // Final cleanup.
  $not_null = function ($el) {
    return isset($el);
  };
  foreach (array(
    'hours',
    'minutes',
    'minTime',
    'maxTime',
  ) as $key) {
    $new[$key] = array_filter($values['timepicker_options'][$key], $not_null);
    if (empty($new[$key])) {
      unset($new[$key]);
    }
  }
  if (!isset($new['rows'])) {

    // Make sure that NULL value is removed from settings.
    unset($new['rows']);
  }

  // Set processed values back.
  form_set_value($element['timepicker_options'], $new, $form_state);
}