You are here

public function JssorFieldFormatter::settingsForm in Jssor Slider 8

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

src/Plugin/Field/FieldFormatter/JssorFieldFormatter.php, line 133
Contains \Drupal\jssor\Plugin\Field\FieldFormatter\JssorFieldFormatter.

Class

JssorFieldFormatter
Plugin for responsive image formatter.

Namespace

Drupal\jssor\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $image_options = array();
  $image_styles = $this->imageStyleStorage
    ->loadMultiple();
  if ($image_styles && !empty($image_styles)) {
    foreach ($image_styles as $machine_name => $image_style) {
      $image_options[$machine_name] = $image_style
        ->label();
    }
  }
  $element['image_style'] = array(
    '#title' => t('Image style'),
    '#type' => 'select',
    '#default_value' => $this
      ->getSetting('image_style'),
    '#required' => TRUE,
    '#options' => $image_options,
  );
  $element['autoplay'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable to auto play.'),
    '#default_value' => $this
      ->getSetting('autoplay'),
  );
  $element['arrownavigator'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Arrow navigator'),
    '#default_value' => $this
      ->getSetting('arrownavigator'),
    '#description' => t('Enable arrow navigator.'),
  );
  $element['bulletnavigator'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Bullet navigator'),
    '#default_value' => $this
      ->getSetting('bulletnavigator'),
    '#description' => t('Enable bullet navigator.'),
  );
  $element['caption'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Caption'),
    '#default_value' => $this
      ->getSetting('caption'),
    '#description' => t('Enable caption.'),
  );
  $element['autoplayinterval'] = array(
    '#type' => 'number',
    '#title' => $this
      ->t('Autoplay interval'),
    '#attributes' => array(
      'min' => 0,
      'step' => 1,
      'value' => $this
        ->getSetting('autoplayinterval'),
    ),
    '#description' => t('Interval (in milliseconds) to go for next slide since the previous stopped.'),
  );
  return $element;
}