<p>After I posted my question I ended up coming with something that works:</p>

<pre><code> {% for entry in craft.entries.section('Vegetables') if entry.Vitamins.contains('a') %}
      &lt;p&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/p&gt;
 {% endfor %}
</code></pre>

CC BY-SA 3.0
2015-10-06T15:49:35.267Z
While this approach works, it seems like we should be able to use the native search() methods and syntax to find entries having checkbox field options checked.
Roger Glenn
CC BY-SA 3.0
2015-06-30T20:40:34.330Z
2015-06-30T20:40:34.330Z
triplethreat23
<p>I posted a similar question the other week, I managed to figure it out and I posted my code. Hope it helps:</p>

<p><a href="https://craftcms.stackexchange.com/questions/10321/filter-based-search-form/10370">Filter based Search Form</a></p>

CC BY-SA 3.0
2015-06-30T22:07:04.800Z
2015-06-30T22:07:04.800Z
2017-04-13T12:51:00.200Z
Jason Mayo
<p>While the approach above works this is how you'd construct a string to use with <code>craft.entries.search()</code> when you have multiple checkbox fields. The benefit is being able to order entries by relevancy/score.</p>

<pre><code>{% set string = '' %}

{% if craft.request.getParam('outcomes') | length %}
    {% for outcome in craft.request.getParam('outcomes') %}
        {% set string = string ~ ' outcomes:' ~ outcome %}
    {% endfor %}
{% endif %}

{% if craft.request.getParam('age') | length %}
    {% for age in craft.request.getParam('age') %}
        {% set string = string ~ ' age:' ~ age %}
    {% endfor %}
{% endif %}

{% if string != '' %}
    {% set entries = craft.entries.section('interventions').search(string).order('score') %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-10-06T16:15:11.477Z
2015-10-06T17:45:31.737Z
2015-10-06T17:45:31.737Z
Roger Glenn
<p>I apologize if this question has been asked before. I'm new at this and am struggling to figure out if what I need to do is possible/the right way to do it or if I need to structure my content differently.</p>

<p>My entries in a section have a field that use a checkbox field type. I would like to display entries that have a matching value based on that field.</p>

<p><strong>Example:</strong>
 Field: Vitamins,</p>

<pre><code>  Field Type: Checkboxes
              Option: Vitamin A  | Value: a
              Option: Vitamin B  | Value: b
              Option: Vitamin C  | Value: c

Section: Vegetables

 -Entry: Broccoli
       Vitamins Field Values: a, c

 -Entry: Corn
       Vitamins Field Values: a, b

 -Entry: Squash
       Vitamins Field Values: a, b, c
</code></pre>

<p>I'm trying to figure out how to display all entries that contain Vitamin A.</p>

<entries>
Display entries with matching checkbox field values
# Display entries with matching checkbox field values

(Asked by: username_0 on 2015-06-30)

I apologize if this question has been asked before. I'm new at this and am struggling to figure out if what I need to do is possible/the right way to do it or if I need to structure my content differently.
My entries in a section have a field that use a checkbox field type. I would like to display entries that have a matching value based on that field.
Example:
 Field: Vitamins,
  Field Type: Checkboxes
              Option: Vitamin A  | Value: a
              Option: Vitamin B  | Value: b
              Option: Vitamin C  | Value: c

Section: Vegetables

 -Entry: Broccoli
       Vitamins Field Values: a, c

 -Entry: Corn
       Vitamins Field Values: a, b

 -Entry: Squash
       Vitamins Field Values: a, b, c

I'm trying to figure out how to display all entries that contain Vitamin A.

**Tags:** entries

---

## 3 answers

### Answer by username_0 on 2015-06-30. Score: 3

After I posted my question I ended up coming with something that works:
 {% for entry in craft.entries.section('Vegetables') if entry.Vitamins.contains('a') %}
      {{ entry.title }}
 {% endfor %}

> **Comments:**
> **username_1**: While this approach works, it seems like we should be able to use the native search() methods and syntax to find entries having checkbox field options checked.  

---

### Answer by username_2 on 2015-06-30. Score: 1

I posted a similar question the other week, I managed to figure it out and I posted my code. Hope it helps:

[Filter based Search Form](https://craftcms.stackexchange.com/questions/10321/filter-based-search-form/10370)


---

### Answer by username_1 on 2015-10-06. Score: 1

While the approach above works this is how you'd construct a string to use with craft.entries.search() when you have multiple checkbox fields. The benefit is being able to order entries by relevancy/score.
{% set string = '' %}

{% if craft.request.getParam('outcomes') | length %}
    {% for outcome in craft.request.getParam('outcomes') %}
        {% set string = string ~ ' outcomes:' ~ outcome %}
    {% endfor %}
{% endif %}

{% if craft.request.getParam('age') | length %}
    {% for age in craft.request.getParam('age') %}
        {% set string = string ~ ' age:' ~ age %}
    {% endfor %}
{% endif %}

{% if string != '' %}
    {% set entries = craft.entries.section('interventions').search(string).order('score') %}
{% endif %}


---

