You are here

public function DateTimeDatelistNoTimeWidget::settingsForm in Datetime Extras 8

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form definition for the widget settings.

Overrides DateTimeDatelistWidget::settingsForm

File

src/Plugin/Field/FieldWidget/DateTimeDatelistNoTimeWidget.php, line 34

Class

DateTimeDatelistNoTimeWidget
Plugin implementation of the 'datetime_datelist_no_time' widget.

Namespace

Drupal\datetime_extras\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['date_order']['#options'] += [
    'Y' => $this
      ->t('Year'),
    'MY' => $this
      ->t('Month/Year'),
    'YM' => $this
      ->t('Year/Month'),
  ];
  $elements['date_year_range'] = [
    '#type' => 'textfield',
    '#title' => t('Date year range'),
    '#description' => "Example: 2000:2010",
    '#default_value' => $this
      ->getSetting('date_year_range'),
  ];
  return $elements;
}