I have a form that generates field per category, so if I have 5 categories, twig will generate 5 category field.
This array consist of 5 categories, so it will loop 5 times.
{% set categories = ['attraction', 'featured_artist', 'co_presentator', 'major_sponsor', 'minor_sponsor'] %} I'll count the total category and deduct it by 1 for the use of for loop. We're using in array so it would be like 0,1,2,3.. etc.
{% set total_category = categories|count -1 %} Now the looping starts here, I have a different column in database, called attraction_image, major_sponsor_image, featured_artist_image. So I have to count the total value in that field per category.
{% for i in 0..total_category %} <div class="increment-field-container" data-increment-host="{{ categories[i] }}"> {% set total_field = details.attraction_image|explode|count %} </div> {% endfor %} How can I concatenate string as variable,
We're calling the total of field like this
{% set total_field = details.attraction_image|explode|count %} But I want to happen is,
{% set total_field = details.categories[i]_image|explode|count %} Technically it would be incorrect:
I tried this String Interpolation thing, but still did not work.
{% set total_field = details."#{categories[i]}"_image|explode|count %} Any solution to this problem?
