<p>Issue was not related to the above code but more due to other loops in template. thanks for comments.</p>

CC BY-SA 3.0
2017-06-05T14:45:33.967Z
2017-06-05T14:45:33.967Z
user6798
<p>I have a multi-select field that I need to test for any 'selected values'...the below always has a return even when no values are selected. How do I check this multi-select to ensure there are selected values to output?</p>

<p>Thanks in advance.</p>

<pre><code>{% if entry.myMultiSelect|length %}
    &lt;!-- Output HTML + option values --&gt;
    {% for option in entry.myMultiSelect%}
        {{ option }}
    {% endfor %}
{% else %}
    &lt;!--Do something else --&gt;               
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-06-01T21:45:56.607Z
You on the latest version of Craft?  I just did a test using your exact code and it works exactly as you'd expect. Outputs the options if there were selections and skips it if there were none.
Brad Bell
CC BY-SA 3.0
2017-06-02T22:54:19.097Z
Hmm, so now that I think about it and re-look @ my code, think it is working correctly but my loops (and there are many) are not in the correct HTML blocks....thanks for your response.
user6798
CC BY-SA 3.0
2017-06-03T00:19:02.400Z
When you get to the bottom of it, would you mind adding your solutions as an official answer?
Brad Bell
<templating>
Multi-Select Tests
# Multi-Select Tests

(Asked by: username_0 on 2017-06-01)

I have a multi-select field that I need to test for any 'selected values'...the below always has a return even when no values are selected. How do I check this multi-select to ensure there are selected values to output?
Thanks in advance.
{% if entry.myMultiSelect|length %}
    
    {% for option in entry.myMultiSelect%}
        {{ option }}
    {% endfor %}
{% else %}
                   
{% endif %}

**Tags:** templating

> **Comments:**
> **username_1**: You on the latest version of Craft?  I just did a test using your exact code and it works exactly as you'd expect. Outputs the options if there were selections and skips it if there were none.  
> **username_0**: Hmm, so now that I think about it and re-look @ my code, think it is working correctly but my loops (and there are many) are not in the correct HTML blocks....thanks for your response.  
> **username_1**: When you get to the bottom of it, would you mind adding your solutions as an official answer?  

---

## 1 answers

### Answer by username_0 on 2017-06-05. Score: 1

Issue was not related to the above code but more due to other loops in template. thanks for comments.


---

