I Want the users to have an expanded advance search form if no results are returned from a search. The advance search form on the search page always defaults to collapsed.
I also can effect the advanced search form's attributes (whether it's collapsed, or maybe display other data inside of the advanced search form, etc) with drupal's
MYTHEME_form_search_form_alter's first call. The issue I have is
MYTHEME_form_search_form_alter() gets called before results are returned.
So I can alter the advance search form first, then I can check if we returned any results from the search... which doesn't help me, because I need it to be vice versa - If I know I have no results then I know to expand the advanced search form's collapsible form.
My quick solution was to invoke
drupal_get_form("search_form", "no_results"); inside of my module's preprocess search hook
MYMODULE_search_preprocess_search_results(&$variables) and just pass in the variable
"no_results". This (as most of you probably know) will invoke
hook_form_search_form_alter again, where I can edit the advance search form now and I will alter the advance search form only if my variable
"no_results" comes through.
Here is my crux though! Even though I am invoking that theme hook again and checking for the variable, when I go to edit the
"advanced" entry... its gone now. So it's clearly there when theme's hook is called, and I can indeed effect the arrays, but if I try to effect the advanced array when I invoke the theme's hook (inside of my module's hook) it's not there. Where would I invoke this theme's hook if not on the module layer? Hell, the theme's preprocess hook is fired AFTER the module's and has proven to be the same circumstance, seems in either of the two ways of checking my results I cannot invoke the form_alter hook and get the exact same form back.
You can see my new variable denoting that we have no result (in this case it's LarryU) under the action key, but there is no advanced key. I tried just remaking it but it doesn't to the form.