function HandlerBase::buildGroupByForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::buildGroupByForm()
  2. 8.9.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::buildGroupByForm()
  3. 10 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::buildGroupByForm()

Provide a form for aggregation settings.

1 call to HandlerBase::buildGroupByForm()
EntityField::buildGroupByForm in core/modules/views/src/Plugin/views/field/EntityField.php
Extend the groupby form with group columns.
1 method overrides HandlerBase::buildGroupByForm()
EntityField::buildGroupByForm in core/modules/views/src/Plugin/views/field/EntityField.php
Extend the groupby form with group columns.

File

core/modules/views/src/Plugin/views/HandlerBase.php, line 337

Class

HandlerBase
Base class for Views handler plugins.

Namespace

Drupal\views\Plugin\views

Code

public function buildGroupByForm(&$form, FormStateInterface $form_state) {
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    $form['#section'] = $display_id . '-' . $type . '-' . $id;
    $this->view
        ->initQuery();
    $info = $this->view->query
        ->getAggregationInfo();
    foreach ($info as $id => $aggregate) {
        $group_types[$id] = $aggregate['title'];
    }
    $form['group_type'] = [
        '#type' => 'select',
        '#title' => $this->t('Aggregation type'),
        '#default_value' => $this->options['group_type'],
        '#description' => $this->t('Select the aggregation function to use on this field.'),
        '#options' => $group_types,
    ];
}

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