You are here

function mefibs_exposed_block_form_submit in MEFIBS - More exposed forms in blocks 7

Custom submit handler for exposed forms.

This code will run before the original submit handler, so we can alter things here.

1 string reference to 'mefibs_exposed_block_form_submit'
mefibs_form_views_exposed_form_alter in ./mefibs.module
Implements hook_form_FORM_ID_alter().

File

./mefibs.module, line 730
Primarily Drupal hooks and global API functions to manipulate views and to provide an additional block with an exposed filter form.

Code

function mefibs_exposed_block_form_submit(&$form, &$form_state) {
  $view = $form_state['view'];
  $block_id = isset($form_state['mefibs_block_id']) ? $form_state['mefibs_block_id'] : NULL;
  if (!$block_id || $block_id == 'default' || !mefibs_display_is_mefibs_enabled($view->display_handler)) {
    return;
  }
  $display_id = $view->current_display;
  $display = $view->display[$display_id]->handler;

  // Check if the reset button for this block is enabled. If so, we need to
  // rewrite the "op" value in order to let views know that the form should be
  // reset.
  $block_settings = $display->extender['mefibs_blocks']
    ->get_block_options($block_id);
  $op_key = mefibs_get_element_name_prefix($block_id) . '-op';
  if (isset($_GET[$op_key]) && $block_settings['reset_button'] && $_GET[$op_key] == $block_settings['reset_button_label']) {
    $form_state['values']['op'] = $display
      ->get_plugin('exposed_form')->options['reset_button_label'];
    unset($_SESSION['mefibs'][$view->name][$display_id]);
  }
}