You are here

public function MediaElementVideoFieldFormatter::settingsForm in MediaElement 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 FileVideoFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/MediaElementVideoFieldFormatter.php, line 208

Class

MediaElementVideoFieldFormatter
Plugin implementation of the 'mediaelement_file_video' formatter.

Namespace

Drupal\mediaelement\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return $this
    ->traitSettingsForm($form, $form_state) + [
    'poster_image_field' => [
      '#title' => $this
        ->t('Poster Image Field'),
      '#description' => $this
        ->t('Select an Image Field from this @entity_type type to use as the poster thumbnail.', [
        '@entity_type' => $this->fieldDefinition
          ->getTargetEntityTypeId(),
      ]),
      '#type' => 'select',
      '#options' => $this
        ->getImageFieldOptions(),
      '#default_value' => $this->settings['poster_image_field'],
    ],
    'poster_image_style' => [
      '#title' => $this
        ->t('Poster Image Style'),
      '#type' => 'select',
      '#options' => $this
        ->getImageStyleOptions(),
      '#default_value' => $this->settings['poster_image_style'],
      '#states' => [
        'invisible' => [
          ':input[name*="poster_image_field"]' => [
            'value' => 'none',
          ],
        ],
      ],
    ],
  ];
}