function views_handler_filter::build_group_submit

Save new group items, re-enumerates and remove groups marked to delete.

1 call to views_handler_filter::build_group_submit()
views_handler_filter::options_submit in handlers/views_handler_filter.inc
Simple submit handler.

File

handlers/views_handler_filter.inc, line 740

Class

views_handler_filter
Base class for filters.

Code

public function build_group_submit($form, &$form_state) {
    $groups = array();
    uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight');
    // Filter out removed items.
    // Start from 1 to avoid problems with #default_value in the widget.
    $new_id = 1;
    $new_default = 'All';
    foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
        if (empty($group['remove'])) {
            // Don't store this.
            unset($group['remove']);
            unset($group['weight']);
            $groups[$new_id] = $group;
            if ($form_state['values']['options']['group_info']['default_group'] === $id) {
                $new_default = $new_id;
            }
        }
        $new_id++;
    }
    if ($new_default != 'All') {
        $form_state['values']['options']['group_info']['default_group'] = $new_default;
    }
    $filter_default_multiple = array_filter($form_state['values']['options']['group_info']['default_group_multiple']);
    $form_state['values']['options']['group_info']['default_group_multiple'] = $filter_default_multiple;
    $form_state['values']['options']['group_info']['group_items'] = $groups;
}