Hi,
due to certain limitations of groups and cloneable fields, I had to create multiple rows/series of regular fields. The pattern is more or less like this:
'series_1_some_field', 'series_1_some_other_field', (...)
'series_2_some_field', 'series_2_some_other_field', (...)
Now I am building a template for an HTML table with all these series of these fields.
I would like to use the iteration (series) number inside the field name, so that I don't have to repeat the same thing over and over again.
Something like that:
{% for i in 1..20 %}
<tr role="row">
<td role="cell"> {{ i }} </td>
<td role="cell"> {{ post.series_[~i~]_some_field }}</td>
<td role="cell"> {{ post.series_[~i~]_some_other_field }} </td>
</tr>
{% endfor %}
I found the 'bracket notation' in Drupal forums, and tried a few variations,
like {{post.[series_~i~_some_field] }} etc. But I cannot make it work, and the official Twig documentation is rather short and doesn't have too many examples.
I know it's super easy with cloneable fields, and I use them normally, but in this case I can't use them.
Is it possible to pass the iteration number inside the field name?
Greetings,
Tom