How to add custom submit logic to search_block_form? I want to alter the input typed into the default search block in a way that when users search for "möp" (with a German umlaut) the search should be broadened to "möp OR moep" automatically.

So I simply tried to append a custom form submit to the search_block_form and simply expand the string by a certain logic. But then I found out that the search_block_form seems to be a little bit special. In core/modules/search/src/Form/SearchBlockForm.php I found the following comment.


  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    // This form submits to the search page, so processing happens there.
  }



My question now is: Where do I actually add the logic exactly if not in the form submit? I don't find any redirect or controller that would help here. Could you please point me in the right direction? Or maybe, you even have a better idea than appending the logic this way?



I removed the D8 tag as I guess the logic behind this is pretty equal amongst all common Drupal versions.
You can do this in hook_search_preprocess():


  Preprocess text for search.
  
  This hook is called to preprocess both the text added to the search
  index and the keywords users have submitted for searching. The same
  processing needs to be applied to both so that searches will find
  matches.


This is not part of the preprocess in theming. This hook is called directly from the search module. Btw. German umlauts are already replaced by default.