You are here

public function Layer::buildOptionsForm in Geolocation Field 8.3

Provide the default form for setting options.

Overrides Attachment::buildOptionsForm

File

src/Plugin/views/display/Layer.php, line 76

Class

Layer
The plugin that handles an attachment display.

Namespace

Drupal\geolocation\Plugin\views\display

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {

  // It is very important to call the parent function here:
  parent::buildOptionsForm($form, $form_state);
  switch ($form_state
    ->get('section')) {
    case 'displays':
      $displays = [];
      foreach ($this->view->storage
        ->get('display') as $display_id => $display) {
        if ($this->view->displayHandlers
          ->has($display_id)) {
          $style = $this->view->displayHandlers
            ->get($display_id)
            ->getOption('style');
          if ($style['type'] == 'maps_common') {
            $displays[$display_id] = $display['display_title'];
          }
        }
      }
      $form['displays'] = [
        '#title' => $this
          ->t('Displays'),
        '#type' => 'checkboxes',
        '#description' => $this
          ->t('Select which display or displays this should attach to.'),
        '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', $displays),
        '#default_value' => $this
          ->getOption('displays'),
      ];
      break;
  }
}