Adding custom submit handler is breaking exposed filter funtionality

Created on 8 November 2016, over 8 years ago
Updated 5 July 2023, almost 2 years ago

I've got a view (I'd include an export, but that appears to be gone in views 8.x) that I'm adding a custom submit handler to via a custom module. However, when the handler is applied, it breaks the view's interpretation of the exposed filter values from the URL. The arguments are present via $_GET, but there are no filter values present in any instance of hook_views_function. When I remove the submit handler, the view functions as expected with the filter values filtering the query.

The I've tried adding the handler in both of the following ways with the same result, although admittedly I do not know if there are any differences between the two:

$form['actions']['submit']['#submit'][] = '_product_search_exposed_form_submit';

and

foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = '_product_search_exposed_form_submit';
      }
    }

Any idea what's going on here? For now I'm going to have to manually construct the filters in hook_views_query_alter(), but it's not exactly preferable.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mrweiner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024