function views_handler_field_field::groupby_form

Extend the groupby form with group columns.

Overrides views_handler::groupby_form

File

modules/field/views_handler_field_field.inc, line 612

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

public 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'),
    ) + 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,
    );
}