function SortPluginBase::buildExposeForm

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/sort/SortPluginBase.php \Drupal\views\Plugin\views\sort\SortPluginBase::buildExposeForm()
  2. 10 core/modules/views/src/Plugin/views/sort/SortPluginBase.php \Drupal\views\Plugin\views\sort\SortPluginBase::buildExposeForm()
  3. 9 core/modules/views/src/Plugin/views/sort/SortPluginBase.php \Drupal\views\Plugin\views\sort\SortPluginBase::buildExposeForm()

Form for exposed handler options.

Overrides HandlerBase::buildExposeForm

File

core/modules/views/src/Plugin/views/sort/SortPluginBase.php, line 195

Class

SortPluginBase
Base sort handler that has no options and performs a simple sort.

Namespace

Drupal\views\Plugin\views\sort

Code

public function buildExposeForm(&$form, FormStateInterface $form_state) {
  // #flatten will move everything from $form['expose'][$key] to $form[$key]
  // prior to rendering. That's why the preRender for it needs to run first,
  // so that when the next preRender (the one for fieldsets) runs, it gets
  // the flattened data.
  array_unshift($form['#pre_render'], [
    get_class($this),
    'preRenderFlattenData',
  ]);
  $form['expose']['#flatten'] = TRUE;
  $form['expose']['label'] = [
    '#type' => 'textfield',
    '#default_value' => $this->options['expose']['label'],
    '#title' => $this->t('Label'),
    '#required' => TRUE,
    '#size' => 40,
    '#weight' => -1,
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.