function views_ui_config_item_group_form

Same name in other branches
  1. 7.x-3.x includes/admin.inc \views_ui_config_item_group_form()

Form to config_item items in the views UI.

1 string reference to 'views_ui_config_item_group_form'
views_ui_ajax_forms in includes/admin.inc

File

includes/admin.inc, line 3290

Code

function views_ui_config_item_group_form(&$form_state) {
    $view =& $form_state['view'];
    $display_id = $form_state['display_id'];
    $type = $form_state['type'];
    $id = $form_state['id'];
    $form = array(
        'options' => array(
            '#tree' => TRUE,
        ),
    );
    if (!$view->set_display($display_id)) {
        views_ajax_render(t('Invalid display id @display', array(
            '@display' => $display_id,
        )));
    }
    $view->init_query();
    $item = $view->get_item($display_id, $type, $id);
    if ($item) {
        $handler = $view->display_handler
            ->get_handler($type, $id);
        if (empty($handler)) {
            $form['markup'] = array(
                '#value' => t("Error: handler for @table > @field doesn't exist!", array(
                    '@table' => $item['table'],
                    '@field' => $item['field'],
                )),
            );
        }
        else {
            $handler->init($view, $item);
            $types = views_object_types();
            $form['#title'] = check_plain($view->display[$display_id]->display_title) . ': ';
            $form['#title'] .= t('Configure group settings for @type %item', array(
                '@type' => $types[$type]['lstitle'],
                '%item' => $handler->ui_name(),
            ));
            $form['#section'] = $display_id . '-' . $type . '-' . $id;
            $info = $view->query
                ->get_aggregation_info();
            foreach ($info as $id => $aggregate) {
                $group_types[$id] = $aggregate['title'];
            }
            $form['group_type'] = array(
                '#type' => 'select',
                '#title' => t('Group type'),
                '#default_value' => $handler->options['group_type'],
                '#description' => t('Grouping is enabled for this display. You must select what function to use on this field.'),
                '#options' => $group_types,
            );
            $form_state['handler'] =& $handler;
        }
        views_ui_standard_form_buttons($form, $form_state, 'views_ui_config_item_group_form');
    }
    return $form;
}