You are here

public function SvgImageFieldWidget::settingsForm in SVG Image Field 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/SvgImageFieldWidget.php \Drupal\svg_image_field\Plugin\Field\FieldWidget\SvgImageFieldWidget::settingsForm()
  2. 2.1.x src/Plugin/Field/FieldWidget/SvgImageFieldWidget.php \Drupal\svg_image_field\Plugin\Field\FieldWidget\SvgImageFieldWidget::settingsForm()

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.

Overrides FileWidget::settingsForm

File

src/Plugin/Field/FieldWidget/SvgImageFieldWidget.php, line 83

Class

SvgImageFieldWidget
Plugin implementation of the 'image_image' widget.

Namespace

Drupal\svg_image_field\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $element['preview_image_max_width'] = [
    '#title' => t('Preview image max width'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('preview_image_max_width'),
    '#weight' => 15,
  ];
  $element['preview_image_max_height'] = [
    '#title' => t('Preview image max height'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('preview_image_max_height'),
    '#weight' => 16,
  ];
  return $element;
}