You are here

public function FileVideoFormatter::settingsForm in File Entity (fieldable files) 8.2

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/FileVideoFormatter.php, line 97

Class

FileVideoFormatter
Plugin implementation of the 'file_video' formatter.

Namespace

Drupal\file_entity\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['controls'] = array(
    '#title' => t('Show video controls'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('controls'),
  );
  $element['autoplay'] = array(
    '#title' => t('Autoplay'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('autoplay'),
  );
  $element['loop'] = array(
    '#title' => t('Loop'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('loop'),
  );
  $element['muted'] = array(
    '#title' => t('Muted'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('muted'),
  );
  $element['playsinline'] = array(
    '#title' => t('Plays inline'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('playsinline'),
  );
  $element['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $this
      ->getSetting('width'),
    '#size' => 5,
    '#maxlength' => 5,
    '#field_suffix' => t('pixels'),
  );
  $element['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => $this
      ->getSetting('height'),
    '#size' => 5,
    '#maxlength' => 5,
    '#field_suffix' => t('pixels'),
  );
  $element['multiple_file_behavior'] = array(
    '#title' => t('Display of multiple files'),
    '#type' => 'radios',
    '#options' => array(
      'tags' => t('Use multiple @tag tags, each with a single source.', array(
        '@tag' => '<video>',
      )),
      'sources' => t('Use multiple sources within a single @tag tag.', array(
        '@tag' => '<video>',
      )),
    ),
    '#default_value' => $this
      ->getSetting('multiple_file_behavior'),
  );
  return $element;
}