I'm creating module to use similiar words to get better search result. I have API which will returns top X similiar words for entered word. What I want to achieve is this workflow:
User enter some word into the search form and submit the form
My module call the API, gets the similiar words and change the search query
--- That is what I have done. But next part is problem ---
- After sucesful search, alter the form to show user the similiar words I used to change the query.
At the start I expected, that I can save similiar words in
hook_search_api_solr_query_alter and then in
hook_form_alter change the form to show the words. But after some research I find out that is not possible, because hooks are called in different order.
Is there any way how I can alter form after submit (or validation)?
I also tried to set
form_state['rebuild'] in validation hook, but when the form is rebuild, the entered values are erased.