Search against a checkboxes field's options I have a relatively simple structure for products that I am building an advanced search for. I access the products using craft.entries.section('products'), but these products have fields with options for those fields within them.

So my question is, how do I access these? This is my attempt so far.

        {% set parameters=
            {
                section: 'products',
                limit: '1'
            }
        %}

        {% set query = craft.request.getParam('entry') %}

        {% if query %}
            {% set entries = craft.entries(parameters).relatedTo(query).order('score') %}
        {% else %}
            {% set entries = craft.entries(parameters) %}
        {% endif %}


I know this is incorrect, because I need to look at an object within an object within products and check a field belonging it. For instance, if the product was a phone, it would have something like "mobilityOptions" and under that would be "Cordless", "Desk", and "Wall". 

My search form has got those mobility options through a for option in products loop of the section, followed by a for block in option.mobilityOptions.options that then makes checkboxes for each option, but to use it with the ".relatedTo" functionality I don't think it would work.
Checkboxes / multiselect fields store to the database in a very query unfriendly way.
That's why I would really recommend to use categories, tags, lightswitches instead, if you intend to
query against these fields' values.

Here's what you'd have to do to search for entries with selected checkboxes field types' options. You basically have to get all relevant entries first,
go through them to check each checkbox option and store the element ID in case the entry is valid. Using this approach you end
up with an array of IDs which you can now query against.

{% set entries = craft.entries.section('news') %}

{% set query = craft.request.getQuery() %}

{% if query.mobilityOptions is defined %}
    {% set ids = [] %}

    {% for entry in entries %}
        {% set valid = true %}

        {% for option in query.mobilityOptions %}
            {% if not entry.mobilityOptions.contains(option) %}
                {% set valid = false %}
            {% endif %}
        {% endfor %}

        {% if valid %}
            {% set ids = ids|merge([entry.id]) %}
        {% endif %}
    {% endfor %}

    {% set entries = craft.entries.id(ids) %}
{% endif %}