You are here

public function ImageLightBoxFormatter::settingsForm in ImageLightbox 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldFormatter/ImagelightboxFormatter.php \Drupal\imagelightbox\Plugin\Field\FieldFormatter\ImageLightBoxFormatter::settingsForm()
  2. 2.0.x src/Plugin/Field/FieldFormatter/ImagelightboxFormatter.php \Drupal\imagelightbox\Plugin\Field\FieldFormatter\ImageLightBoxFormatter::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 ImageFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/ImagelightboxFormatter.php, line 40

Class

ImageLightBoxFormatter
Plugin implementation of the 'imagelightbox' formatter.

Namespace

Drupal\imagelightbox\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $settings = $this
    ->getSettings();
  $image_styles = image_style_options(FALSE);
  $element['image_style'] = [
    '#title' => t('Image style'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('image_style'),
    '#empty_option' => t('None (original image)'),
    '#options' => $image_styles,
  ];
  $element['imagelightbox_image_style'] = $element['image_style'];
  $element['imagelightbox_image_style']['#title'] = t('ImageLightBox image style (default)');
  $element['imagelightbox_image_style']['#default_value'] = $this
    ->getSetting('imagelightbox_image_style');
  $element['captions_source'] = [
    '#title' => t('Captions source'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('captions_source'),
    '#options' => $this
      ->captionsSourceOptions(),
  ];
  $element['inline'] = [
    '#title' => t('Display as inline elements'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('inline'),
  ];
  return $element;
}