You are here

public function VideoPlayerFormatter::settingsForm in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/VideoPlayerFormatter.php \Drupal\video\Plugin\Field\FieldFormatter\VideoPlayerFormatter::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

File

src/Plugin/Field/FieldFormatter/VideoPlayerFormatter.php, line 95

Class

VideoPlayerFormatter
Plugin implementation of the 'video_player' formatter.

Namespace

Drupal\video\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['width'] = [
    '#title' => t('Width'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('width'),
    '#required' => TRUE,
  ];
  $element['height'] = [
    '#title' => t('Height'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('height'),
    '#required' => TRUE,
  ];
  $element['controls'] = [
    '#title' => t('Show controls'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('controls'),
  ];
  $element['autoplay'] = [
    '#title' => t('Autoplay'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('autoplay'),
  ];
  $element['loop'] = [
    '#title' => t('Loop'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('loop'),
  ];
  $element['muted'] = [
    '#title' => t('Muted'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('muted'),
  ];
  $element['preload'] = [
    '#title' => t('Preload'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('preload'),
    '#options' => [
      'none' => 'none',
      'metadata' => 'metadata',
      'auto' => 'auto',
    ],
    '#description' => t('Hint to the browser about whether optimistic downloading of the video itself or its metadata is considered worthwhile.'),
  ];
  return $element;
}