# ACF repeater fields in Gutenberg blocks

**URL:** <https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998>\
**Category:** Blocks\
**Tags:** acfpro\
**Created:** [April 22, 2020, 2:47pm UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998 "2020-04-22T14:47:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![samboldweb](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/samboldweb/32/2581_2.png) [@samboldweb](https://forum.pinegrow.com/u/samboldweb)\
**Post date:** [April 22, 2020, 2:47pm UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/1 "2020-04-22T14:47:51Z")

</div>

Hi Guys, does anyone know how to implement repeater fields inside pinegrow new block building? We use the repeater function a lot in websites so I was wondering how Pinegrow supported that?

---

<div class="post-metadata">

**Author:** ![Roel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/roel/32/1753_2.png) [@Roel](https://forum.pinegrow.com/u/Roel)\
**Post date:** [April 23, 2020, 12:19am UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/2 "2020-04-23T00:19:21Z")

</div>

You can do it, I’ve done it myself a few times. It is only possible to do it with the PHP code action, not the ACF field action though.

Here is the procedure:

Make a span around the html elements that you want repeated (technically you don’t need the span per se but in my opinion, this makes it easier to implement from a workflow standpoint) and add a PHP code action to it in the wordpress tab. Next, copy the top part of your repeater code into the field labeled “function with params” (for instance: _if( have\_rows(‘block’) ): while ( have\_rows(‘block’) ) : the\_row();_ , just replace the “block” monicker here with the name of the repeater field) and set the ‘replace’ select field to “insert before”.

Next, add another php code action to the same element and paste the following code into it: _endwhile; else : endif;_.  
And set the ‘replace’ select field to “insert after”. What this will do is wrap your chosen html elements into a repeater function. (You could also add the php code actions to the first element and the last element respectively, instead of doing this with a span. It will give exactly the same result but as I said earlier, I prersonally prefer using a span).

Than add a block action to the element encompassing that. (For instance, another span, wrapping the span you used for the php code actions).

Make sure you set the field group location where your repeater field is located to the acf block you registered with the block action.

Let me know whether you get it working.

---

<div class="post-metadata">

**Author:** ![samboldweb](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/samboldweb/32/2581_2.png) [@samboldweb](https://forum.pinegrow.com/u/samboldweb)\
**Post date:** [April 23, 2020, 1:38pm UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/3 "2020-04-23T13:38:59Z")

</div>

Thanks for the detailed response, wasn’t expecting that. Ill try this out. Thank you

---

<div class="post-metadata">

**Author:** ![Roel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/roel/32/1753_2.png) [@Roel](https://forum.pinegrow.com/u/Roel)\
**Post date:** [May 10, 2020, 1:32pm UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/4 "2020-05-10T13:32:36Z")

</div>

Did it work for you?

---

<div class="post-metadata">

**Author:** ![alfan](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@alfan](https://forum.pinegrow.com/u/alfan)\
**Post date:** [May 16, 2020, 6:40am UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/5 "2020-05-16T06:40:56Z")

</div>

Just wanted to say Thank you to Roel for the detailed guide. I followed your guide and It worked 👍

---

<div class="post-metadata">

**Author:** ![aliveli](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@aliveli](https://forum.pinegrow.com/u/aliveli)\
**Post date:** [July 18, 2021, 6:08am UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/6 "2021-07-18T06:08:39Z")

</div>

@alfan @Roel could you share a working example (pinegrow folder with a simple html file) please? It would be better us to understand.  
So much thanks.

---

<div class="post-metadata">

**Author:** ![jtkay](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jtkay](https://forum.pinegrow.com/u/jtkay)\
**Post date:** [July 1, 2022, 12:52am UTC](https://forum.pinegrow.com/t/acf-repeater-fields-in-gutenberg-blocks/3998/7 "2022-07-01T00:52:37Z")

</div>

Is this the most current way to do a repeater?
