<p>Yes, this is possible using the <a href="https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">Twig Loop variable</a>. The following will add the current iteration of the loop.</p>
<pre><code>{% for row in block.buttons %}
    {{ loop.index }}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2022-02-04T18:11:16.250Z
Perfect.  Thank you!
fodney
CC BY-SA 4.0
2022-02-11T08:23:02.533Z
Beware that `index` starts at 1. If you need 0-indexed, use `index0`.
PWL
CC BY-SA 4.0
2022-02-03T21:23:26.423Z
2022-02-03T21:23:26.423Z
Anna_MediaGirl
<p>I need a unique id for each table row.  Something like this which does not work:</p>
<p><code>{% for row in block.buttons %}{{ row.id }}{% endfor %}</code></p>
<p>Is this possible?</p>
<p>Thanks!</p>

<templating><table-field>
Table Field Row ID?
# Table Field Row ID?

(Asked by: username_0 on 2022-02-03)

I need a unique id for each table row. Something like this which does not work:

`{% for row in block.buttons %}{{ row.id }}{% endfor %}`

Is this possible?

Thanks!

**Tags:** templating, table-field

---

## 1 answers

### Answer by username_1 on 2022-02-03. Score: 1

Yes, this is possible using the Twig Loop variable. The following will add the current iteration of the loop.
{% for row in block.buttons %}
    {{ loop.index }}
{% endfor %}

> **Comments:**
> **username_0**: Perfect.  Thank you!  
> **username_2**: Beware that `index` starts at 1. If you need 0-indexed, use `index0`.  

---

