I have a text field that has three values on new lines.
E01001667
E01001668
E01000779
I want to use these for a query that looks like this:
{% set mylsoas = craft.entries.
section('imdData')
.orWhere(['in', 'content.field_lsoacode', ['E01001667','E01001668','E01000779']])
.all() %}
The above query works and returns the records I want when i add the values directly. However I need to build the where params dynamically from the text field values so I am doing this:
{% set lsoas = uentry.selectedLsoas | split("\n") %}
{% set whereParams = null %}
{# trim and join #}
{% for ons in lsoas %}
{% set whereParams = whereParams ~ "'"~ons~"'," %}
{% endfor %}
{% set whereParams = "[" ~ whereParams|trim(',', 'right') ~ "]" %}
The output of whereParams on screen works in the query and give me this:
{{ whereParams }}
outputs: ['E01001667','E01001668','E01000779']
But when i pass the variable in to the query i get a zero results - no errors.
{% set mylsoas = craft.entries.
section('imdData')
.orWhere(['in', 'content.field_lsoacode', whereParams])
.all() %}
At a loss to get this working. Any ideas welcome:)