function SortPluginBase::buildExposeForm

Same name in other branches
  1. 8.9.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. 11.x core/modules/views/src/Plugin/views/sort/SortPluginBase.php \Drupal\views\Plugin\views\sort\SortPluginBase::buildExposeForm()

Overrides HandlerBase::buildExposeForm

File

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

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'], [
        static::class,
        '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,
    ];
    $form['expose']['field_identifier'] = [
        '#type' => 'textfield',
        '#default_value' => $this->options['expose']['field_identifier'],
        '#title' => $this->t('Sort field identifier'),
        '#required' => TRUE,
        '#size' => 40,
        '#description' => $this->t("This will appear in the URL after the ?, as value of 'sort_by' parameter, to identify this sort field. Cannot be blank. Only letters, digits and the dot ('.'), hyphen ('-'), underscore ('_'), and tilde ('~') characters are allowed."),
    ];
}

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