You are here

public function FileMediaFormatterBase::settingsForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::settingsForm()
  2. 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase::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 FormatterBase::settingsForm

1 call to FileMediaFormatterBase::settingsForm()
FileVideoFormatter::settingsForm in core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php
Returns a form to configure settings for the formatter.
1 method overrides FileMediaFormatterBase::settingsForm()
FileVideoFormatter::settingsForm in core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php
Returns a form to configure settings for the formatter.

File

core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatterBase.php, line 43

Class

FileMediaFormatterBase
Base class for media file formatter.

Namespace

Drupal\file\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return [
    'controls' => [
      '#title' => $this
        ->t('Show playback controls'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('controls'),
    ],
    'autoplay' => [
      '#title' => $this
        ->t('Autoplay'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('autoplay'),
    ],
    'loop' => [
      '#title' => $this
        ->t('Loop'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('loop'),
    ],
    'multiple_file_display_type' => [
      '#title' => $this
        ->t('Display of multiple files'),
      '#type' => 'radios',
      '#options' => [
        'tags' => $this
          ->t('Use multiple @tag tags, each with a single source.', [
          '@tag' => '<' . $this
            ->getHtmlTag() . '>',
        ]),
        'sources' => $this
          ->t('Use multiple sources within a single @tag tag.', [
          '@tag' => '<' . $this
            ->getHtmlTag() . '>',
        ]),
      ],
      '#default_value' => $this
        ->getSetting('multiple_file_display_type'),
    ],
  ];
}