I am writing a module that lets users save 'searches' made using exposed filters.
The idea is that I use hook_form_alter to add my checkbox to the exposed filters form, as well as add my own submit handler to the form. In my submit handler I find out if the checkbox was selected, and if it was I save the exposed filter inputs to my database table along with information about the user.
It just seems that Views does not want me to do this, because some funky things happen when I do. For one, views thinks that the checkbox I have created is actually part of the exposed filter options. Thus, when I hit 'Apply' and the page reloads showing the filtered results, I see a '&save=1' appended to the URI's query string ('save' being the name of my form element). Because of this, the checkbox always has a default value of being checked when the page is reloaded, which I don't want. I can get around this by explicitly redefining my form element in the submit handler, but Views still attempts to add something to the query string, but this time it gets confused and just adds '&='.
I feel like I might be able to hack my around this, but something about this whole approach just feels wrong. Is there a proper way to mess around with exposed filters? Or are they always doomed to be unalterable?
Comments
Here is a thread showing how
Here is a thread showing how to alter exposed filters into checkboxes. Perhaps you can get some clues from there.
Be sure to alter the form by reference.
Do you have this module...
ready yet?