You are here

function FilterPluginBase::build_group_submit in Views (for Drupal 7) 8.3

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

1 call to FilterPluginBase::build_group_submit()
FilterPluginBase::submitOptionsForm in lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
Simple submit handler

File

lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php, line 639
Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.

Class

FilterPluginBase
Base class for filters.

Namespace

Drupal\views\Plugin\views\filter

Code

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;
}