function DateTimeRangeTrait::dateTimeRangeSettingsForm

Same name in other branches
  1. 11.x core/modules/datetime_range/src/DateTimeRangeTrait.php \Drupal\datetime_range\DateTimeRangeTrait::dateTimeRangeSettingsForm()

Configuration form for date time range.

Parameters

array $form: The form array.

Return value

array Modified form array.

3 calls to DateTimeRangeTrait::dateTimeRangeSettingsForm()
DateRangeCustomFormatter::settingsForm in core/modules/datetime_range/src/Plugin/Field/FieldFormatter/DateRangeCustomFormatter.php
Returns a form to configure settings for the formatter.
DateRangeDefaultFormatter::settingsForm in core/modules/datetime_range/src/Plugin/Field/FieldFormatter/DateRangeDefaultFormatter.php
Returns a form to configure settings for the formatter.
DateRangePlainFormatter::settingsForm in core/modules/datetime_range/src/Plugin/Field/FieldFormatter/DateRangePlainFormatter.php
Returns a form to configure settings for the formatter.

File

core/modules/datetime_range/src/DateTimeRangeTrait.php, line 68

Class

DateTimeRangeTrait
Provides friendly methods for datetime range.

Namespace

Drupal\datetime_range

Code

protected function dateTimeRangeSettingsForm(array $form) : array {
    $form['from_to'] = [
        '#type' => 'select',
        '#title' => $this->t('Display'),
        '#options' => $this->getFromToOptions(),
        '#default_value' => $this->getSetting('from_to'),
    ];
    $field_name = $this->fieldDefinition
        ->getName();
    $form['separator'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Date separator'),
        '#description' => $this->t('The string to separate the start and end dates'),
        '#default_value' => $this->getSetting('separator'),
        '#states' => [
            'visible' => [
                'select[name="fields[' . $field_name . '][settings_edit_form][settings][from_to]"]' => [
                    'value' => DateTimeRangeConstantsInterface::BOTH,
                ],
            ],
        ],
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.