1 views_handler_field_field.inc views_handler_field_field::groupby_form(&$form, &$form_state)

Extend the groupby form with group columns.

Overrides views_handler::groupby_form

File

core/modules/field/views/views_handler_field_field.inc, line 639
Definition of views_handler_field_field.

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

function groupby_form(&$form, &$form_state) {
  parent::groupby_form($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'),
  ) + backdrop_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 = backdrop_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,
  );
}