Answers.Body: <p>The problem was that I used this code within an entry, so I had to use the tag of that entry (offer) instead of entry.</p>
  
  <p>The code that works now is: </p>
  
  <pre><code>{% for option in offer.offerMinimumPrice.options %}
    {% if option.selected %}
      {{ option }}
    {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T10:43:30.980Z
Answers.LastActivityDate: 2015-09-22T10:43:30.980Z
Answers.UserDisplayName: sanderfish
Answers.Body: <p>If you want a comma-separated list of selected options, try this.</p>
  
  <pre><code>{% for option in offer.offerMinimumPrice.options|filter(v =&gt; v.selected) %}
      {{ option.label }}{% if loop.last==false %}, {% endif %}
  {% endfor %}
  </code></pre>
  
  <p><code>for</code> provides a <a href="https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">loop</a> object that provides many useful variables.</p>
  
  <p><a href="https://twig.symfony.com/doc/2.x/filters/filter.html" rel="nofollow noreferrer">filter</a> can be used to filter down items in a list or map using an arrow function. Given that <code>selected</code> is a boolean, you just need to return the value.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-25T19:44:17.423Z
Answers.LastActivityDate: 2019-10-25T19:44:17.423Z
Answers.UserDisplayName: Critical Mash
Answers.Body: <p>Try this instead:</p>
  
  <pre><code>{% for option in entry.offerMinimumPrice %} 
      {{ option }}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T19:09:49.540Z
Answers.Text: Hi, thanks for answering. Unfortunately, that doesn't return any values as well.
Answers.UserDisplayName: sanderfish
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T19:06:15.043Z
Answers.LastActivityDate: 2015-09-21T19:06:15.043Z
Answers.UserDisplayName: andrew.welch
Body: <p>I'm trying to build a filter and for that I want my client to be able to select a few options, which I use as classes for in my filter. </p>
  
  <p>I chose for a checkbox field and set it up in the backend. Now I'm trying to retrieve the data on the HTML side, but I can only retrieve ALL values, instead of only the selected ones. </p>
  
  <p>This is how my HTML/twig markup looks like</p>
  
  <pre><code>{% for option in entry.offerMinimumPrice.options %} 
    {% if option.selected %}
      {{ option }}
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>With this code none of the values gets displayed in the front end. When I remove the conditional statement, all values get displayed (instead of only the selected ones).</p>
  
  <p>Can anyone tell me what I'm doing wrong? Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-22T02:55:09.603Z
Comments.Text: The code you have should be working fine.  Are you sure you're looking at the correct entry and that entry actually has something checked in the `offerMinimumPrice` field?
Comments.UserDisplayName: Brad Bell
Tags: <field><conditional><forloop><checkboxes>
Title: Can't get checkboxfield values to show
ThreadText: # Can't get checkboxfield values to show
  
  (Asked by: username_0 on 2015-09-21)
  
  I'm trying to build a filter and for that I want my client to be able to select a few options, which I use as classes for in my filter.
  
  I chose for a checkbox field and set it up in the backend. Now I'm trying to retrieve the data on the HTML side, but I can only retrieve ALL values, instead of only the selected ones.
  
  This is how my HTML/twig markup looks like
  
  ```
  {% for option in entry.offerMinimumPrice.options %} 
    {% if option.selected %}
      {{ option }}
    {% endif %}
  {% endfor %}
  
  ```
  
  With this code none of the values gets displayed in the front end. When I remove the conditional statement, all values get displayed (instead of only the selected ones).
  
  Can anyone tell me what I'm doing wrong? Thanks!
  
  **Tags:** field, conditional, forloop, checkboxes
  
  > **Comments:**
  > **username_1**: The code you have should be working fine.  Are you sure you're looking at the correct entry and that entry actually has something checked in the `offerMinimumPrice` field?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-09-22. Score: 2 | Accepted answer
  
  The problem was that I used this code within an entry, so I had to use the tag of that entry (offer) instead of entry.
  
  The code that works now is:
  
  ```
  {% for option in offer.offerMinimumPrice.options %}
    {% if option.selected %}
      {{ option }}
    {% endif %}
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2019-10-25. Score: 2
  
  If you want a comma-separated list of selected options, try this.
  
  ```
  {% for option in offer.offerMinimumPrice.options|filter(v => v.selected) %}
      {{ option.label }}{% if loop.last==false %}, {% endif %}
  {% endfor %}
  
  ```
  
  `for` provides a [loop](https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable) object that provides many useful variables.
  
  [filter](https://twig.symfony.com/doc/2.x/filters/filter.html) can be used to filter down items in a list or map using an arrow function. Given that `selected` is a boolean, you just need to return the value.
  
  
  ---
  
  ### Answer by username_3 on 2015-09-21. Score: 0
  
  Try this instead:
  
  ```
  {% for option in entry.offerMinimumPrice %} 
      {{ option }}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hi, thanks for answering. Unfortunately, that doesn't return any values as well.  
  
  ---
  
  