Ok, it's not pretty. This is what I have come up with:
1. Rewrite the HTML select/options (these would have to be hard-coded anyway since by default Matrix allows single-selection only, which doesn't meet our requirements). Rewrite in such a way that rather than the checkboxes all having the same name, and thereby creating an array, each checkbox is instead uniquely named. E.g.
...
...
...
...
There is also logic in there for adding 'checked' attributes (or is called a property?) on options selected in the search (useful as in my case I'm continuously showing these options including on result pages).
2. Leave the Matrix Search Page fields configuration as is, in my case a GET parameter called 'doctype' to match on a specific metadata field, set to OR logic.
3. In the standard page embedding the search form add a nested GET variable, in my case I called doctype, update to this value (yes, using the "one Matrix keyword to rule them all" approach):
...
...
...
...
So why does this work?
- Selecting multiple checkboxes and submitting now submits a query string that has uniquely named args, specifically:
?option1=show&option2=show...
So the globals_get keywords in the variables section on the embedding page can now handle it correctly (Matrix globals_get keyword doesn't handle array values at all, as stated in manuals).
-
The sequence of keywords in the GET variables in the embedding page handles each of these options separately and outputs a value followed by a comma. (You could in fact customise what these search values are to match your metadata keys, if required, at this point). Fortunately Matrix Search page allows you to have a comma on the end and is forgiving and runs the search as expected. Were it not for that none of this would work.
-
Interestingly it doesn't matter what the value for the options is set to, since you are a translating/mapping them in the nested variable anyway. You can even leave the value attribute off completely. Due to the nature of how checkboxes are handled it will default to a value of 'on' if checked, unchecked ones do not even get a a param set at all, and so our logic only has to check that the param was set, specific value is irrelevant.
It's not all good news
Above approach requires a lot of manual coding HTML. Not a problem in my case as I was going to have to manually code it anyway, but updates will be that much more difficult. Each time a new option is added or an existing one updated I'm going to have to come in here and change not only the options list but also the big keywords list in the embedding page. Again, in my case this list will change very infrequently so it's ok, but if you are going to be changing the options frequently then this may not be an ideal solution.
Edit: Wanted to also say Nic is absolutely right, this could be accomplished with a handful of lines of javascript. Sometimes I like to see if something *can* be done a certain way - one of my character flaws. In fact, if you wanted a highly dynamic solution you could use the built-in Matrix selector, hide it, and use JS to generate a list of checkboxes directly in the DOM. For frequently updated options this would be an ideal solution as the checkboxes would automatically generate based on your metadata field values.