You are here

public function VeflBasic::buildOptionsForm in Views exposed form layout 8

Provide a form to edit options for this plugin.

Overrides ExposedFormPluginBase::buildOptionsForm

File

src/Plugin/views/exposed_form/VeflBasic.php, line 40

Class

VeflBasic
Exposed form plugin that provides a basic exposed form with layout.

Namespace

Drupal\vefl\Plugin\views\exposed_form

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $layout_id = $this->options['layout']['layout_id'];
  $layouts = Vefl::getLayouts();

  // Outputs layout selectbox.
  $form['layout'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Layout settings'),
  ];
  $form['layout']['layout_id'] = [
    '#prefix' => '<div class="container-inline">',
    '#type' => 'select',
    '#options' => Vefl::getLayoutOptions($layouts),
    '#title' => $this
      ->t('Layout'),
    '#default_value' => $layout_id,
  ];
  $form['layout']['change'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Change'),
    '#submit' => [
      [
        $this,
        'updateRegions',
      ],
    ],
    '#suffix' => '</div>',
  ];
  $form['layout']['widget_region'] = VeflBasic::getRegionElements($layout_id, $layouts);
}