I am trying to modify the form action of the search block in my Drupal 8 project. The search block is placed in the Primary menu area. I added the following code in my .theme file
function mytheme_form_alter(&$form, FormStateInterface $form_state, $form_id) {
echo 'my search form'.$form_id;
}
This form alter is not called when the page is loaded.
I tried adding form_alter in my custom module. It is also not working. Any ideas?
I found the answer. We can change the form action in block--search.html.twig file in the theme folder.