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 %}
    <!-- Output HTML + option values -->
    {% for option in entry.myMultiSelect%}
        {{ option }}
    {% endfor %}
{% else %}
    <!--Do something else -->               
{% endif %}
  • 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
    Commented Jun 1, 2017 at 21:45
  • 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
    Commented Jun 2, 2017 at 22:54
  • When you get to the bottom of it, would you mind adding your solutions as an official answer?
    – Brad Bell
    Commented Jun 3, 2017 at 0:19

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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