You are here

public function ColorboxFieldFormatterImage::settingsForm in Colorbox field formatter 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldFormatter/ColorboxFieldFormatterImage.php \Drupal\colorbox_field_formatter\Plugin\Field\FieldFormatter\ColorboxFieldFormatterImage::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 ColorboxFieldFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/ColorboxFieldFormatterImage.php, line 33

Class

ColorboxFieldFormatterImage
Plugin implementation of the 'colorbox_field_formatter' formatter for images.

Namespace

Drupal\colorbox_field_formatter\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form = parent::settingsForm($form, $form_state);
  $image_styles = image_style_options(FALSE);
  $image_styles['hide'] = $this
    ->t('Hide (do not display image)');
  $form['image_style'] = [
    '#title' => $this
      ->t('Content image style'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('image_style'),
    '#empty_option' => $this
      ->t('None (original image)'),
    '#options' => $image_styles,
    '#description' => $this
      ->t('Image style to use in the content.'),
  ];
  return $form;
}