You are here

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

@inheritdoc

Overrides ExposedFormPluginBase::exposedFormAlter

File

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

Class

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

Namespace

Drupal\vefl\Plugin\views\exposed_form

Code

public function exposedFormAlter(&$form, FormStateInterface $form_state) {
  parent::exposedFormAlter($form, $form_state);
  $view = $form_state
    ->get('view');
  $layout_id = $this->options['layout']['layout_id'];
  $widget_region = $this->options['layout']['widget_region'];
  $form['#vefl_configuration'] = [
    'layout' => [
      'id' => $layout_id,
      'settings' => [],
    ],
    'regions' => [],
  ];
  foreach ($widget_region as $field_name => $region) {
    $form['#vefl_configuration']['regions'][$region][] = $field_name;

    // Provides default wrapper settings for Display suite layout.
    if (substr($layout_id, 0, 3) == 'ds_') {
      $form['#vefl_configuration']['layout']['settings']['wrappers'][$region] = 'div';
    }
  }
  $form['#theme'] = $view
    ->buildThemeFunctions('vefl_views_exposed_form');
}