1

I am probably doing something daft here, but tried multiple things to no resolution. I trying to find if a value is in an array but my test case doesn't match.

{% if entry.applicationStatus == 'submitted' %}{% endif %}   # matches ok             
{% if entry.applicationStatus in ['submitted'] %}{% endif %} # doesn't match

The array check in the above case doesn't match. entry.applicationStatus is a dropdown menu. I will want to check for multiple values which is why I want to check if it is in an array.

1

I've bumped into this a few times. It's because entry.fieldHandleName when used on a field type with multiple options (dropdowns/radios etc) is in fact a magic shortcut for entry.fieldHandleName.value. You can see this if you dump out the variable to the screen: <pre>{{ dump(entry.applicationStatus) }}</pre>.

So, you need to append .value on to the end: {% if entry.applicationStatus.value in ['submitted'] %}{% endif %}

1
  • Ah - makes perfect sense. Thanks!
    – mmc501
    Jun 21 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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