You are here

public function DrupalSliderThumbnails::buildOptionsForm in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/DrupalSliderThumbnails.php \Drupal\drupal_slider\Plugin\views\field\DrupalSliderThumbnails::buildOptionsForm()

Provide the options form.

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/DrupalSliderThumbnails.php, line 39

Class

DrupalSliderThumbnails
Field handler for Drupal Slider.

Namespace

Drupal\drupal_slider\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $form['relationship']['#access'] = FALSE;
  $form['thumbnails'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Thumbnails image url'),
    '#description' => $this
      ->t("Give the Thumbnail image URL token"),
    '#default_value' => $this->options['thumbnails'],
  ];
  $form['replacements'] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => $this
      ->t('Replacement Variables'),
  ];
  $views_fields = $this->view->display_handler
    ->getHandlers('field');
  foreach ($views_fields as $field => $handler) {
    if ($field == $this->options['id']) {
      break;
    }
    $items[] = "{{ {$field} }}";
  }
  $form['replacements']['variables'] = [
    '#theme' => 'item_list',
    '#items' => $items,
  ];
  parent::buildOptionsForm($form, $form_state);
}