You are here

public function SortPluginBase::buildExposeForm in Drupal 8

Same name and namespace in other branches
  1. 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,
  ];
}