You are here

public function InstagramEmbedFormatter::settingsForm in Media entity Instagram 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/InstagramEmbedFormatter.php \Drupal\media_entity_instagram\Plugin\Field\FieldFormatter\InstagramEmbedFormatter::settingsForm()
  2. 3.x src/Plugin/Field/FieldFormatter/InstagramEmbedFormatter.php \Drupal\media_entity_instagram\Plugin\Field\FieldFormatter\InstagramEmbedFormatter::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/InstagramEmbedFormatter.php, line 116

Class

InstagramEmbedFormatter
Plugin implementation of the 'instagram_embed' formatter.

Namespace

Drupal\media_entity_instagram\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['width'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Width'),
    '#default_value' => $this
      ->getSetting('width'),
    '#min' => 320,
    '#description' => $this
      ->t('Max width of instagram.'),
  ];
  $elements['hidecaption'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Caption hidden'),
    '#default_value' => $this
      ->getSetting('hidecaption'),
    '#description' => $this
      ->t('Enable to hide caption of Instagram posts.'),
  ];
  return $elements;
}