Set simple boolean in twig
symfony, twig
Solution
You cannot use statements in an expression. Removing `if` will do the trick:
{% set zyx = 'small' in question['answers'] %}
EDIT
To check if `answer.small` is `true`, use:
{% set zyx = question['answers']['small'] is true %}
Problem
lets say i have some data like this : ``` answers: [ { answerText: "please", small: false }, { answerText: "help", small: true }, { answerText: "me", small: false } ], ``` and i want to set a boolean that´s true if there is an answer where small is true. and i need to use it outside the loop i´m iterating over answers. im trying arround and just dont get it, i think my nearest attempt is sth. like this ``` {% set zyx = if 'small' in question['answers'] %} {% set zyx = 'small' in question['answers'] %} {% set zyx = 'small:true' in question['answers'] %} {% set zyx = true in question['answers'] %} ``` but they all dont work as i expect for any help thanks in advance