Reputation: 781
I am testing if a value exists in an array in my twig template
<input type="hidden" name="s" value="{{ search_value }}">
<label>
<input type="checkbox"
name="cat[]"
value="3"
onchange="this.form.submit()"
{% if 3 in cat ? ' checked' : '' %} >
<span>cbd</span>
</label>
{{ cat }}
My {{ cat }}
dumps array on the page, I'm sure my problem is a silly syntax error. The error i get is
Fatal error: Uncaught Exception: Unexpected end of template. in....
if I wrap in this way I get a different error
{% (if 3 in cat) ? ' checked' : '' %} >
Fatal error: Uncaught Exception: A block must start with a tag name.
Upvotes: 0
Views: 419