Add an additional custom submit handler to default search api Solr view filter? I would like to run an additional submit handler every time a user searches a term with the default view filter provided by the search_api_solr module.

Here is my form altering code:

/**
 * Implements hook_form_FORM_ID_alter.
 */
function my_module_form_views_exposed_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-solr-search-content-page-1') {
    $form['#submit'][] = 'my_module_handler';
  }
}

**
 * Custom submit handler.
 */
function my_module_handler(array $form, FormStateInterface $form_state) {
  drupal_set_message($form_state-&gt;getValue('keys'));
}


The problem is the that submit handler executes twice. It executes when the page loads (I think) and when the 'Search' button is clicked. Any ideas why this would be?

(I am trying to write all the terms searched by users (strings) to a database table.)

Thanks.
The solution was to enable AJAX on the view. This stopped the page refreshing and the double form submission.