You are here

public function SmartDateDurationFormatter::settingsForm in Smart Date 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()
  2. 3.x src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()
  3. 3.1.x src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()
  4. 3.2.x src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()
  5. 3.3.x src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()
  6. 3.4.x src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDurationFormatter::settingsForm()

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 SmartDateDefaultFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/SmartDateDurationFormatter.php, line 40

Class

SmartDateDurationFormatter
Plugin implementation of a duration-based formatter for 'smartdate' fields.

Namespace

Drupal\smart_date\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // Use the upstream settings form, which gives us a control to override the
  // timezone.
  $form = parent::settingsForm($form, $form_state);

  // Ask the user to choose a Smart Date Format.
  $smartDateFormatOptions = $this
    ->getAvailableSmartDateFormatOptions();
  $form['duration_separator'] = [
    '#type' => 'text',
    '#title' => $this
      ->t('Duration Separator'),
    '#description' => $this
      ->t('Choose which display configuration to use.'),
    '#default_value' => $this
      ->getSetting('duration_separator'),
  ];
  return $form;
}