You are here

public function FotoramaGalleryFormatter::settingsForm in Fotorama Gallery 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/FotoramaGalleryFormatter.php \Drupal\fotorama_gallery\Plugin\Field\FieldFormatter\FotoramaGalleryFormatter::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/FotoramaGalleryFormatter.php, line 118

Class

FotoramaGalleryFormatter
Plugin implementation of the 'fotorama_gallery display' formatter.

Namespace

Drupal\fotorama_gallery\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  unset($element['image_link']);
  $url_options = [
    'attributes' => [
      'target' => '_blank',
    ],
  ];

  // Field groups.
  $element['dimensions'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Dimensions'),
    '#description' => Link::fromTextAndUrl($this
      ->t('Documentation: Dimensions'), Url::fromUri('http://fotorama.io/customize/dimensions/', $url_options)),
  ];
  $element['others'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Others'),
  ];
  $element['autoplay'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Autoplay'),
  ];
  $element['navigation'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Navigation'),
  ];
  $element['transition'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Transition'),
  ];

  // Specials fields.
  $element['dimensions']['ratio'] = [
    '#type' => 'textfield',
    '#open' => 1,
    '#title' => $this
      ->t('Ratio'),
    '#size' => 10,
    '#default_value' => $this
      ->getSetting('dimensions')['ratio'],
  ];

  // Common fields.
  $this
    ->settingsFormSelectsFields($element, $url_options);
  $this
    ->settingsFormCheckBoxFields($element, $url_options);
  $this
    ->settingsFormNumberFields($element);
  return $element;
}