1

Lets say I have this form

{exp:low_search:form collection="members" secure="no" search_mode="any" loose_ends="yes" result_page="flatmates/"}
    <fieldset>
        <p>Age</p>
        <select class="span5" name="range-from:age" id="age_from">
            <option></option>
            <option value="18">18</option>
            <option value="19">19</option>
            ....
            <option value="65">65</option>
        </select>

        <select class="span5" name="range-to:age" id="age_to">
            <option></option>
            <option value="18">18</option>
            <option value="19">19</option>
            ....
            <option value="65">65</option>
        </select>
    </fieldset>
{/exp:low_search:form}  

What happens to the search results when I make it so that the "from" is greater than the "to" value or the "to" value less than "from"(for example, if I choose 40 for the "from" and then 18 for the "to"?

How does Low Search handle this? Does it somehow swap them or intepret the lesser value as the "from" and the greater value as the "to"? Or does it do nothing(no swaps, no errors, etc)?

2

Low Search will do what you tell it to do. So, if you set the from-value to 40 and the to-value to 18, it will search for field >= 40 AND field <= 18, which will return no results. No swapping, no errors.

If you need validation, you can take care of that on the front-end, using JavaScript. Or use pre-defined date ranges in a single <select> element, for example:

 <select name="range:age">
     <option value="">Select age</option>
     <option value=";17">Under 18</option>
     <option value="18;25">18 - 25</option>
     <option value="25;35">25 - 35</option>
     <option value="35;50">35 - 50</option>
     <option value="50;">50+</option>
</select>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.