---
title: How to handle repeater fields in automation?
date: 2025-02-02T17:46:29Z
modified: 2026-09-22T19:51:44Z
permalink: "https://techarticles.co.uk/how-to-handle-repeater-fields-in-automation/"
type: post
status: publish
excerpt: ""
wpid: 4466
categories:
  - Automation
  - Blog
  - Coding
  - FlowMattic
  - Fluent Forms
  - Wordpress
timestamp: 2026-09-22T19:51:44Z
tags:
  - Automation
  - Blog
  - Coding
  - FlowMattic
  - Fluent Forms
  - Wordpress
---

One of my most requested videos in the last few months has been how to handle repeaters/iterators/loops in [FlowMattic](https://ta0.uk/flowmattic), and in this article and the accompanying video, I will share some additional details on how to do that with a real-world example.

One of the reasons I haven’t created this video is that I was struggling with a real-world example, but then one fell into my lap just a few hours after it became clear that it would be the winner of my poll within the FlowMattic Facebook group.

![Poll results on video topics, showing "FlowMatic - Repeaters" leading with 47%, followed by options on integration setup and tips.](https://techarticles.co.uk/wp-content/uploads/2025/02/Flowmattic_next_video_poll.png)

## What’s the example?

A question was asked of me by email from someone to assist them in creating a custom solution to allow them to a) issue unique tickets and b) issue an email to each delegate and a cover email to the booker for an event they were looking to host.

I knew I would use fluent forms and their [repeater input field](https://wpmanageninja.com/docs/fluent-form/field-types/repeat-field/) for this, and of course, my recommendation for automation here would be Flowmattic. They have a module to help deal with such data, the [iterator module.](https://help.flowmattic.com/docs/features/iterator-module-159/)

## Some Important things to note!

In my video and example, I haven’t used the FlowMattic fluent forms integration, and the reason for this is all around how FlowMattic iterators work. It needs JSON data to work, not the form data the fluent forms integration puts into its flow. So I have used a webhook trigger, and again, please note you don’t want to enable a simple response as you need that JSON data to loop/iterate.

![Flowmattic webhook capture setup interface with options for URL, authentication, and response format settings.](https://techarticles.co.uk/wp-content/uploads/2025/02/flowmattic-webhook-no-simple-data.png)

## Let’s Start with the form!

This all starts with the form; now, in my example, I am using fluent forms as I have fluent forms. It has a repeater input field, and I know how to use it effectively. Repeater Fields is a pro item, as is webhook sending with fluent forms, I believe, so remember that to follow this tutorial, you will need a pro fluent form. Most form plugins have repeater fields and webhooks, but you must check how they all work, although I expect for almost all of them they will be “pro” or “premium” features.

So moving on to the booking form, it’s actually quite simple. A screengrab is shown below:

![Conference booking form with fields for name, email, and company; section for delegate details and a submit button.](https://techarticles.co.uk/wp-content/uploads/2025/02/Fluentform-confrence-booking-example.png)

As you can see, we have a lead booker, which is often the case for a conference or ticket booking and the names and email addresses of the delegates attending our FlowMattic conference, the highlight fields in purple are our fluent form repeater fields, and you add a new row by pushing the plus button the arrow is pointing too.

So this is the basis of our data, and what will get sent to Flowmattic on submission. This is set to trigger our flowmattic webhook, and an example of that data is shown below

![Fluentform database showing submission details with user info, repeater fields, and headers in tabular format.](https://techarticles.co.uk/wp-content/uploads/2025/02/Fluent-form-submission-data-repeaters-tutorial-example.png)

**Please note** our repeater fields are separated and repeating as they should be. In this example, we have five submissions for tickets to loop through below is an overview of our workflow, which is relatively small but hopefully illustrates how our flow will work

![FlowMatti workflow diagram starting with webhooks, iterating through delegates, generating tickets, sending emails, and resetting tables.](https://techarticles.co.uk/wp-content/uploads/2025/02/repeater-flowmattic-workflow-example.png)

So we start with our webhook, and then we “loop” through our delegates and generate a ticket number for them which is secure and unique we then send the delegate their ticket number to there email address and add their name and ticket number to the table which at the end of our loop will be sent to the primary booker, and then we iterate this through our example.

So, in the example of the webhook data we have above this image, we would generate five tickets and send five emails to those delegates; we then end our iterator.

**Please Note:** Ending iterators is only necessary if you are doing steps outside of your iterator, so if all you are doing is looping, you don’t need to add an end to the iteration.

It should also be noted that FlowMattic has a native iterator store module for storing data similar to my add ticket details function, but I wanted this as an HTML table, so I have chosen to do it with PHP sessions and adding table rows and resetting the table outside of the flow

So the below image is our looped section before this, and after this is our standard flow but this is our iterator and handles our repeater fields.

![FlowMatic repeater loop diagram showing iterator, PHP functions, and email steps.](https://techarticles.co.uk/wp-content/uploads/2025/02/our-repeater-loop-in-flowmattic.png)

We then move on once we have done all our looping, and we move to pull our completed table with what would be our five delegates and their five ticket numbers. we then send an email to the booker which contains this information. See the email snippet below:

![Delegate ticket list for Flowmattic Con with unique ticket numbers.](https://techarticles.co.uk/wp-content/uploads/2025/02/deligate-emails-flowmattic-repeater.png)

Finally we then end our flow by resetting the table ready for the next session run.

In this flow, I have used four PHP snippets/functions, and they are all recreated below for you in the code block listed below

- Generate a Ticket – this generates our unique ticket number and stores it in the database so we know they are unique and not duplicated. They are hashed for security and uniqueness. 
    generateUniqueTicketNumber()
- Add Ticket Details – This adds a row to our table using the addTableRow() function. This needs a Name and ticket variable
- Get Order Delegate table – this is how we get our HTML table to input into our outgoing email getTable()
- Reset table – resetTable() resets the table ready for the next flow run.

```
<span class="line"><span style="color: #F97583"><?</span><span style="color: #79B8FF">php</span><span style="color: #E1E4E8"> </span></span>
<span class="line"><span style="color: #79B8FF">session_start</span><span style="color: #E1E4E8">(); </span><span style="color: #6A737D">// Start session to store table data</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// Function to add a row to the table</span></span>
<span class="line"><span style="color: #F97583">function</span><span style="color: #E1E4E8"> </span><span style="color: #B392F0">addTableRow</span><span style="color: #E1E4E8">($name, $ticket) {</span></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">if</span><span style="color: #E1E4E8"> (</span><span style="color: #F97583">!</span><span style="color: #79B8FF">isset</span><span style="color: #E1E4E8">($_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">])) {</span></span>
<span class="line"><span style="color: #E1E4E8">        $_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">] </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> [];</span></span>
<span class="line"><span style="color: #E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #6A737D">// Store row as an array</span></span>
<span class="line"><span style="color: #E1E4E8">    $_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">][] </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> [</span></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #9ECBFF">'name'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">=></span><span style="color: #E1E4E8"> </span><span style="color: #79B8FF">htmlspecialchars</span><span style="color: #E1E4E8">($name),</span></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #9ECBFF">'ticket'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">=></span><span style="color: #E1E4E8"> </span><span style="color: #79B8FF">htmlspecialchars</span><span style="color: #E1E4E8">($ticket),</span></span>
<span class="line"><span style="color: #E1E4E8">    ];</span></span>
<span class="line"><span style="color: #E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// Function to generate the HTML table as a string (returns table)</span></span>
<span class="line"><span style="color: #F97583">function</span><span style="color: #E1E4E8"> </span><span style="color: #B392F0">getTable</span><span style="color: #E1E4E8">() {</span></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">if</span><span style="color: #E1E4E8"> (</span><span style="color: #79B8FF">empty</span><span style="color: #E1E4E8">($_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">])) {</span></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #F97583">return</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'<p>No entries available.</p>'</span><span style="color: #E1E4E8">;</span></span>
<span class="line"><span style="color: #E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    $html </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'<table border="1" cellpadding="5" cellspacing="0">'</span><span style="color: #E1E4E8">;</span></span>
<span class="line"><span style="color: #E1E4E8">    $html </span><span style="color: #F97583">.=</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'<tr><th>Delegate</th><th>Ticket</th></tr>'</span><span style="color: #E1E4E8">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">foreach</span><span style="color: #E1E4E8"> ($_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">] </span><span style="color: #F97583">as</span><span style="color: #E1E4E8"> $row) {</span></span>
<span class="line"><span style="color: #E1E4E8">        $html </span><span style="color: #F97583">.=</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'<tr><td>'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">.</span><span style="color: #E1E4E8"> $row[</span><span style="color: #9ECBFF">'name'</span><span style="color: #E1E4E8">] </span><span style="color: #F97583">.</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'</td><td>'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">.</span><span style="color: #E1E4E8"> $row[</span><span style="color: #9ECBFF">'ticket'</span><span style="color: #E1E4E8">] </span><span style="color: #F97583">.</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'</td></tr>'</span><span style="color: #E1E4E8">;</span></span>
<span class="line"><span style="color: #E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    $html </span><span style="color: #F97583">.=</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'</table>'</span><span style="color: #E1E4E8">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">return</span><span style="color: #E1E4E8"> $html; </span><span style="color: #6A737D">// Returns the table as a string</span></span>
<span class="line"><span style="color: #E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// Function to reset/clear the table</span></span>
<span class="line"><span style="color: #F97583">function</span><span style="color: #E1E4E8"> </span><span style="color: #B392F0">resetTable</span><span style="color: #E1E4E8">() {</span></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #79B8FF">unset</span><span style="color: #E1E4E8">($_SESSION[</span><span style="color: #9ECBFF">'table_rows'</span><span style="color: #E1E4E8">]);</span></span>
<span class="line"><span style="color: #E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F97583">function</span><span style="color: #E1E4E8"> </span><span style="color: #B392F0">generateUniqueTicketNumber</span><span style="color: #E1E4E8">() {</span></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">global</span><span style="color: #E1E4E8"> $wpdb; </span><span style="color: #6A737D">// Assuming this runs within a WordPress environment</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    $table_name </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> $wpdb</span><span style="color: #F97583">-></span><span style="color: #E1E4E8">prefix </span><span style="color: #F97583">.</span><span style="color: #E1E4E8"> </span><span style="color: #9ECBFF">'event_tickets'</span><span style="color: #E1E4E8">; </span><span style="color: #6A737D">// Adjust the table name accordingly</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">do</span><span style="color: #E1E4E8"> {</span></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #6A737D">// Generate a secure UUID</span></span>
<span class="line"><span style="color: #E1E4E8">        $uuid </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> </span><span style="color: #79B8FF">bin2hex</span><span style="color: #E1E4E8">(</span><span style="color: #B392F0">random_bytes</span><span style="color: #E1E4E8">(</span><span style="color: #79B8FF">16</span><span style="color: #E1E4E8">)); </span></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #6A737D">// Shorten the ticket number using SHA-256 and truncate</span></span>
<span class="line"><span style="color: #E1E4E8">        $ticketNumber </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> </span><span style="color: #79B8FF">strtoupper</span><span style="color: #E1E4E8">(</span><span style="color: #79B8FF">substr</span><span style="color: #E1E4E8">(</span><span style="color: #79B8FF">hash</span><span style="color: #E1E4E8">(</span><span style="color: #9ECBFF">'sha256'</span><span style="color: #E1E4E8">, $uuid), </span><span style="color: #79B8FF">0</span><span style="color: #E1E4E8">, </span><span style="color: #79B8FF">12</span><span style="color: #E1E4E8">));</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">        </span><span style="color: #6A737D">// Check if the ticket number already exists</span></span>
<span class="line"><span style="color: #E1E4E8">        $exists </span><span style="color: #F97583">=</span><span style="color: #E1E4E8"> $wpdb</span><span style="color: #F97583">-></span><span style="color: #B392F0">get_var</span><span style="color: #E1E4E8">($wpdb</span><span style="color: #F97583">-></span><span style="color: #B392F0">prepare</span><span style="color: #E1E4E8">(</span></span>
<span class="line"><span style="color: #E1E4E8">            </span><span style="color: #9ECBFF">"</span><span style="color: #F97583">SELECT</span><span style="color: #9ECBFF"> </span><span style="color: #79B8FF">COUNT</span><span style="color: #9ECBFF">(</span><span style="color: #F97583">*</span><span style="color: #9ECBFF">) </span><span style="color: #F97583">FROM</span><span style="color: #9ECBFF"> </span><span style="color: #E1E4E8">$table_name</span><span style="color: #9ECBFF"> </span><span style="color: #F97583">WHERE</span><span style="color: #9ECBFF"> ticket_number </span><span style="color: #F97583">=</span><span style="color: #9ECBFF"> %s"</span><span style="color: #E1E4E8">,</span></span>
<span class="line"><span style="color: #E1E4E8">            $ticketNumber</span></span>
<span class="line"><span style="color: #E1E4E8">        ));</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    } </span><span style="color: #F97583">while</span><span style="color: #E1E4E8"> ($exists </span><span style="color: #F97583">></span><span style="color: #E1E4E8"> </span><span style="color: #79B8FF">0</span><span style="color: #E1E4E8">); </span><span style="color: #6A737D">// Ensure uniqueness</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #6A737D">// Store the ticket number in the database</span></span>
<span class="line"><span style="color: #E1E4E8">    $wpdb</span><span style="color: #F97583">-></span><span style="color: #B392F0">insert</span><span style="color: #E1E4E8">($table_name, [</span><span style="color: #9ECBFF">'ticket_number'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">=></span><span style="color: #E1E4E8"> $ticketNumber, </span><span style="color: #9ECBFF">'issued_at'</span><span style="color: #E1E4E8"> </span><span style="color: #F97583">=></span><span style="color: #E1E4E8"> </span><span style="color: #B392F0">current_time</span><span style="color: #E1E4E8">(</span><span style="color: #9ECBFF">'mysql'</span><span style="color: #E1E4E8">)]);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E1E4E8">    </span><span style="color: #F97583">return</span><span style="color: #E1E4E8"> $ticketNumber;</span></span>
<span class="line"><span style="color: #E1E4E8">}</span></span>
<span class="line"></span>
```PHP

![](https://i.ytimg.com/vi/eFB9e_HvMjs/maxresdefault.jpg)