public function Field::buildGroupByForm

Extend the groupby form with group columns.

Overrides HandlerBase::buildGroupByForm

File

drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php, line 622
Definition of Drupal\field\Plugin\views\field\Field.

Class

Field
A field that displays fieldapi fields.

Namespace

Drupal\field\Plugin\views\field

Code

public function buildGroupByForm(&$form, &$form_state) {
  parent::buildGroupByForm($form, $form_state);

  // With "field API" fields, the column target of the grouping function
  // and any additional grouping columns must be specified.
  $group_columns = array(
    'entity_id' => t('Entity ID'),
  ) + drupal_map_assoc(array_keys($this->field_info['columns']), 'ucfirst');
  $form['group_column'] = array(
    '#type' => 'select',
    '#title' => t('Group column'),
    '#default_value' => $this->options['group_column'],
    '#description' => t('Select the column of this field to apply the grouping function selected above.'),
    '#options' => $group_columns,
  );
  $options = drupal_map_assoc(array(
    'bundle',
    'language',
    'entity_type',
  ), 'ucfirst');

  // Add on defined fields, noting that they're prefixed with the field name.
  $form['group_columns'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Group columns (additional)'),
    '#default_value' => $this->options['group_columns'],
    '#description' => t('Select any additional columns of this field to include in the query and to group on.'),
    '#options' => $options + $group_columns,
  );
}