You are here

public function DateTimeDayDefaultFormatter::settingsForm in Date time day 8

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. 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 elements for the formatter settings.

Overrides DateTimeDefaultFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/DateTimeDayDefaultFormatter.php, line 47

Class

DateTimeDayDefaultFormatter
Plugin implementation of the 'Default' formatter for 'datetimeday' fields.

Namespace

Drupal\date_time_day\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form = parent::settingsForm($form, $form_state);
  $form['format_type']['#title'] = $this
    ->t('Day format');
  $form['format_type']['#description'] = $this
    ->t("Choose a format for displaying the day. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date.");
  $form['time_format_type'] = [
    '#type' => 'select',
    '#title' => t('Time format'),
    '#description' => t("Choose a format for displaying the time. Be sure to set a format appropriate for the field, i.e. omitting date for a field that only has a time."),
    '#options' => $form['format_type']['#options'],
    '#default_value' => $this
      ->getSetting('time_format_type'),
  ];
  $form['day_separator'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Day separator'),
    '#description' => $this
      ->t('The string to separate the day and start, end times'),
    '#default_value' => $this
      ->getSetting('day_separator'),
  ];
  $form['time_separator'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Time separator'),
    '#description' => $this
      ->t('The string to separate start, end times'),
    '#default_value' => $this
      ->getSetting('time_separator'),
  ];
  return $form;
}