You are here

public function VideoJsPlayerFormatter::settingsForm in Video.js (HTML5 Video Player) 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 FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/VideoJsPlayerFormatter.php, line 101
Contains \Drupal\videojs\Plugin\Field\FieldFormatter\VideJsPlayerFormatter.

Class

VideoJsPlayerFormatter
Plugin implementation of the 'videojs_player' formatter.

Namespace

Drupal\videojs\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' => array(
      '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;
}