You are here

public function OEmbedFormatter::settingsForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php \Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter::settingsForm()
  2. 10 core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php \Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter::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

core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php, line 249

Class

OEmbedFormatter
Plugin implementation of the 'oembed' formatter.

Namespace

Drupal\media\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return parent::settingsForm($form, $form_state) + [
    'max_width' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Maximum width'),
      '#default_value' => $this
        ->getSetting('max_width'),
      '#size' => 5,
      '#maxlength' => 5,
      '#field_suffix' => $this
        ->t('pixels'),
      '#min' => 0,
    ],
    'max_height' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Maximum height'),
      '#default_value' => $this
        ->getSetting('max_height'),
      '#size' => 5,
      '#maxlength' => 5,
      '#field_suffix' => $this
        ->t('pixels'),
      '#min' => 0,
    ],
  ];
}