Using Multi-Select with Low Search
Hi Low,
I've got a dropdown menu in a search form that allows the user to filter the results by the status. They'd like to be able to filter the results by multiple statuses at once, so I've just tried changing this to a multi-select.
But when I search and select more than one option in this multi-select, the results are only filtering by a single status.
Any ideas what I'm doing wrong here? Or is it not possible to use a multi-select?
Here's a simplified version of my code:
{exp:low_search:form collection="ls_event_search" search_mode="all" result_page="/searches/entry-full-results" secure="no" query="{segment_4}"}
<label>Keywords</label>
<input type="text" name="keywords" id="keywords" value="{keywords}" size="40" />
<label>Status</label>
<select name="status" multiple="multiple" size="5">
<option value="not closed|Deleted">Any</option>
<option value="Not Entered">Not Entered</option>
<option value="Submitted">Submitted</option>
<option value="Approved">Approved</option>
<option value="Cancelled">Cancelled</option>
</select>
<input type="submit" value="Search" />
{/exp:low_search:form}
Thanks,
Stephen
Replies
Low 5 Jun 2013 06:56
Hi Stephen,
You need to change the name of the select-element to status[] to allow for multiple selections.
One side note, tho: it's not possible to combine inclusive and exclusive values. Think of it like the actual status="" parameter. You can mimic anything that the native param can, so status="not closed" or status="submitted|approved", but not status="cancelled|submitted|not closed".
Stephen 5 Jun 2013 10:28
Hi Low,
Thanks for this. I've just amended the name and I'm now getting multiple results.
I also take your point about mixing up the use of 'not'. I guess that worked fine when I was using a dropdown menu and wasn't mixing them up as I was only using one at a time, but I can see what you mean if I move to a multi-select so I've got rid of it (my alternative for having an 'any' option is to select all statuses by default).
I think I might have just picked up a bug though. My multi-select now looks like this:
That status of 'Not Entered' is actually the status name itself of 'Not Entered,' rather than 'not Entered' with a status name of 'Entered.' I find that if I select all of the above values, I don't get all of the results. But if I select all of the values except for the 'Not Entered' status, I get the correct number of results. If I select 'Not Entered' on its own (in either a dropdown or a multi-select), it works fine.
Does this sound like a bug to you, given that 'Not Entered' seems to work in most other situations okay? Or do you have any other ideas?
Thanks,
Stephen
Low 5 Jun 2013 10:47
I thought that status might give you trouble.
I've checked things natively, and this produces all entries:
...so it seems EE's check for "not" is case insensitive. And I'm just setting the parameter value and let EE do the rest. You might need to change the name of that status.
Stephen 5 Jun 2013 11:01
Hi Low,
Thanks for checking and confirming it's an EE thing, and I'll change that status to 'Not-Entered' to avoid the issue.
Thanks,
Stephen