You are here

public function VideoEmbedPlayerFormatter::settingsForm in Video 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/VideoEmbedPlayerFormatter.php \Drupal\video\Plugin\Field\FieldFormatter\VideoEmbedPlayerFormatter::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/VideoEmbedPlayerFormatter.php, line 69

Class

VideoEmbedPlayerFormatter
Plugin implementation of the video field formatter.

Namespace

Drupal\video\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form = [];
  $form['autoplay'] = [
    '#title' => t('Autoplay'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('autoplay'),
  ];
  $form['related_videos'] = [
    '#title' => t('Related Videos'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('related_videos'),
  ];
  $form['width'] = [
    '#title' => t('Width'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('width'),
    '#required' => TRUE,
  ];
  $form['height'] = [
    '#title' => t('Height'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('height'),
    '#required' => TRUE,
  ];
  return $form;
}