Unable to do exact string match on multiselect value

SELECT 'FR' AS country_name
UNION
SELECT 'JP'
ORDER BY 1 ASC

{% form %}

select_parameter:
  type: select
  default: 'FR'
  options:
    labels: country_name
    values: country_name

multiselect_parameter:
  type: multiselect
  default: 'FR'
  options:
    labels: country_name
    values: country_name

{% endform %}

--works
SELECT
{% if select_parameter == 'FR' %}
    'you selected FR'
{% endif %};

--fails
SELECT
{% if multiselect_parameter == 'FR' %}
    'you selected FR'
{% endif %};

Could someone explain what's happening here? I realize that this is not the correct way to use the multiselect parameter, however, it's unclear to me why this isn't working because the return value should match the "FR" string exactly.

Does multiselect return some other type? It works when I do:

{% if multiselect_parameter contains 'FR' %}

So the string is definitely there.

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hey Anshu M ! While other parameters are of type string, multiselects are array-like - hence why testing on equality against a string doesn't work.

    I would use contains in this case - see Liquid Operators for more information!

    Reply Like
Like Follow
  • 7 days agoLast active
  • 1Replies
  • 59Views
  • 2 Following

Create A New Discussion

Share your thoughts