You are here

public function DateWidgetBase::settingsForm in Date 8

Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().

File

lib/Drupal/date/Plugin/field/widget/DateWidgetBase.php, line 68
Definition of Drupal\date\Plugin\field\widget\DateWidgetBase.

Class

DateWidgetBase
Abstract class for all date widgets.

Namespace

Drupal\date\Plugin\field\widget

Code

public function settingsForm(array $form, array &$form_state) {
  $field = $this->field;
  $instance = $this->instance;
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  if (empty($settings['date_date_format'])) {
    $settings['date_date_format'] = variable_get('date_format_html_date', 'Y-m-d') . ' ' . variable_get('date_format_html_time', 'H:i:s');
  }
  $element = array(
    '#element_validate' => array(
      'date_field_widget_settings_form_validate',
    ),
  );
  $element['year_range'] = array(
    '#type' => 'date_year_range',
    '#default_value' => $settings['year_range'],
    '#fieldset' => 'date_format',
    '#weight' => 6,
  );
  $element['increment'] = array(
    '#type' => 'select',
    '#title' => t('Time increments'),
    '#default_value' => $settings['increment'],
    '#options' => array(
      1 => t('1 minute'),
      5 => t('5 minute'),
      10 => t('10 minute'),
      15 => t('15 minute'),
      30 => t('30 minute'),
    ),
    '#weight' => 7,
    '#fieldset' => 'date_format',
  );
  $context = array(
    'field' => $field,
    'instance' => $instance,
  );
  drupal_alter('date_field_widget_settings_form', $element, $context);
  return $element;
}