You are here

public function SoundcloudEmbedFormatter::settingsForm in Media entity Soundcloud 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/SoundcloudEmbedFormatter.php \Drupal\media_entity_soundcloud\Plugin\Field\FieldFormatter\SoundcloudEmbedFormatter::settingsForm()
  2. 3.x src/Plugin/Field/FieldFormatter/SoundcloudEmbedFormatter.php \Drupal\media_entity_soundcloud\Plugin\Field\FieldFormatter\SoundcloudEmbedFormatter::settingsForm()

@inheritDoc

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/SoundcloudEmbedFormatter.php, line 39

Class

SoundcloudEmbedFormatter
Plugin implementation of the 'soundcloud_embed' formatter.

Namespace

Drupal\media_entity_soundcloud\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['type'] = [
    '#title' => $this
      ->t('Type'),
    '#type' => 'select',
    '#options' => [
      'visual' => $this
        ->t('Visual'),
      'classic' => $this
        ->t('Classic'),
    ],
    '#default_value' => $this
      ->getSetting('type'),
    '#description' => $this
      ->t('The type of embed.'),
  ];
  $elements['width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Width'),
    '#default_value' => $this
      ->getSetting('width'),
    '#min' => 1,
    '#required' => TRUE,
    '#description' => $this
      ->t('Width of embedded player.'),
  ];
  $elements['height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Height'),
    '#default_value' => $this
      ->getSetting('height'),
    '#min' => 1,
    '#required' => TRUE,
    '#description' => $this
      ->t('Height of embedded player. Suggested values: 450px for the visual type and 166px for classic.'),
  ];
  $elements['options'] = [
    '#title' => $this
      ->t('Options'),
    '#type' => 'checkboxes',
    '#default_value' => $this
      ->getSetting('options'),
    '#options' => $this
      ->getEmbedOptions(),
  ];
  return $elements;
}