Collecting Repeatable Data in WordPress Forms

Tray of cookies on pink background header image

Collecting repeatable data is a frequent need when building WordPress forms. Whether you're registering players for a team, recording employees working for a company, or purchasing multiple configurable products on a single checkout form you'll need a way to collect repeatable data.

In this article, we'll show you an effortless way to obtain and work with repeatable data and fields by utilizing Gravity Forms and the 3rd-party plugin, GF Nested Forms by Gravity Wiz.

The Scenario

Let's work with the first example. We're registering players for a soccer team. Sorry, I'm American. I agree "football" is a much better word for the sport.

We need to collect some information about the team and some information about each player on the team. If we only need to obtain a small amount of very simple data (e.g., player name, email and jersey number), we could just use a List field and call it a day. Sure, the simple inputs would not validate that the Email is a valid email address and the Jersey Number is, in fact, a number, but it's a workable solution.

3 Column Form List Example

What if we need to collect a more robust set of data for each player? The List field just won't cut it.

Solution? Gravity Forms Nested Forms.

Getting Started

Hi, I'm Dave, the lead developer at Gravity Wiz and a core Gravity Forms developer. I developed Gravity Forms Nested Forms as a solution for folks wanting to collect complex repeatable data with near full support for all Gravity Forms' core functionality.

GF Nested Forms is part of Gravity Perks, a suite of over 29 premium Gravity Forms add-ons. If you're not already a Gravity Perks user, pick up a copy now and join thousands of delighted customers who find new ways Gravity Perks can help them every day.

Let's dive in and see exactly how GF Nested Forms will work as a powerful repeater, registering players for our team.

Creating a Player Registration Form

We'll start by creating a player registration form. This form will have all of the details we want to collect for each player.

Player Registration Form Editor Screenshot

Creating a Team Registration Form

Now let's create a form called Team Registration. This form will have all of the details we want to collect for the team.

- Team Name (Single Line Text field)
- Team City (Drop Down field)
- League (Drop Down field)
- Players (Nested Form field)

Team Registration Form Editor Screenshot

Configuring Your Nested Form Field

Ready for the fun part?! The Nested Form field allows you to select another form which will be used to collect data and attach it to the current forms' submissions. How does this work? Clicking the Add Entry button will load the nested form in a modal (a pop-up inside the current window). After submitting the nested form, a child entry is created and attached to the parent submission.

Go ahead and open up the field settings for the Nested Form and let's get it configured.

  1. Select the "Player Registration" form in the Nested Form setting.
    This will cause the Display Fields setting to appear.
  2. Select a few of the most important, identifying fields in the Display Fields setting.
    You don't want to crowd your parent form with too much information. One of the nice things about Nested Forms is the separation of information. When using fields that can be easily repeated, the user only sees what they need to, and nothing that they don't. As forms become simpler, they become easier to maintain and can even increase your conversion rates.
  3. Change the Entry Labels to "Player" and "Players".
    The Entry Labels will be used through the Nested Form field settings to better identify what the nested entry represents (in this case, a player).

Players Jersey Number Form Editor Nested Field Settings

Take It for a Spin

In it's simplest form (pun intended?), we're done. Here is a simplified demo from the Nested Forms documentation:

Simplified Demo

Screenshot of the Form Demo

Doing Cool Stuff with Nested Entries

Let's take our example even further (and a moment to appreciate how compelling that last headline was).

Registering Multiple Users

We want to register each player as a WordPress user on the website so they can edit their own profile. Easy enough.

On the Player Registration form, we'll use the Gravity Forms User Registration add-on to add a "Create User" feed so that a user will be registered every time the form is submitted. We'll assume you already are familiar with feed-based add-ons but if not, here's a full walkthrough of this process.

GF Nested Forms handles ensuring nested form submissions will not trigger feeds until after the parent form has been submitted. This means the players won't be registered as WordPress users until after the Team Registration form has been submitted successfully.

Charge for Nested Entries

Another cool thing you can do with nested entries is to use them in Gravity Forms calculations. If we wanted to charge a small fee for each player registration, we could handle this on the Team Registration form.

  1. Team Registration Fee Form Editor Field SettingsAdd a Product field to the Team Registration form.
  2. Set the Field Type to Calculated.
  3. Set the Formula setting to the Nested Form field merge tag with our special :count modifier multiplied by whatever fee you would like to charge per player.
    For example, if you want to count the number of players submitted (the nested field in our example has a field ID of 5) multiply it by 10, your merge tag would look something like this:
    {Players:5:count} * 10

Whenever someone is adding a new player, the field total will increase by $10.

Want to see it in action? Check out the demo.

For more ways you can use nested entries in Gravity Forms calculations, check out the docs on Gravity Wiz.

Powerful, Flexible, Repeatable Data Collection

These examples just scratch the surface of what is possible with this powerful plugin. GF Nested Forms is the most advanced repeater solution available for the world's most powerful WordPress form plugin, Gravity Forms.

Have a question about using Nested Forms to power your next project? Leave a comment below and I'll be happy to advise.

Share This
14 Responses to "Collecting Repeatable Data in WordPress Forms"
  1. ccappel says:

    So my form uses GPNF to collect a group of members into a group membership. The umbrella membership as a unique id. How do I include that in the notifications that go to each member, which only access data from the nested form itself, and not the parent? Also, how do I access email addresses entered on the nested form to send each a copy of the parent form notification? I know it's probably obvious, but trying to use the allfields plugin didn't work so I'm missing something.

  2. David Smith says:

    Hi ccappel, as a Gravity Perks user, we'll be happy to help you via support.

  3. David Shipston says:

    I'm using the Gravity Perks add on to collect repeatable data and my question is about exporting the entries.

    From what I can tell, you can only export entries/fields for one form at a time, meaning that any data collected via a nested form won't be included.

    Is there a way that I can export all of the data related to a single form in one export?

    • David Smith says:

      Missed this, David. You are correct, Nested Forms does not support exporting the child entry data at this time. It's on the short list.

    • Roy says:

      Hope this will going to be able to do in nearby future. Don't know if this is possible with for example formidable.? Hope willing to hope so. I've invested in licenses for Gravity Forms, Gravity Perks, Gravityviews and also WPdatatables.

      Gravityviews can not handle nested forms (Gravity Perks), WPdatables can not give me output of 2 tables in one export (or for example rows or merged cells or something) Gravity views does not seem be able to combine to data sources.. or can it?

      Just trying to make a editable web-version of a excel with project information above the entries of type of work, hours, costs (with a formula).

  4. Paul Kimbell says:

    Is there anyway to use conditional logic to fields within the nested form on the parent form?

  5. Tim says:

    I've successfully created a "single line text" field that is dynamically populated. When a user clicks on a linked line of text, that text is entered into the form. A new (repeated) single line text is then added but it includes the same text as the previous entry.
    Is there a way to add a new (repeated) "single line of text" field that changes (without effecting the first) when the user clicks another linked line of text?

  6. Joe says:

    Great work. This is exactly what I'm looking for, but I need it to work on all devices. Any idea when you expect to have a version that works for mobile?

    Thanks!

  7. Marlon says:

    I think the repeating fields feature should be a native GF function.

  8. Keviin says:

    Hello 🙂
    I'm thinking of buying this nested forms.

    I have a question:
    I can see here in your screenshots that the output is a table.. Will there be other options?

  9. Farshad says:

    Hi,
    Thanks for you great article. Can you help me use the new builtin gravity repeatable form capability?

    https://docs.gravityforms.com/repeater-fields/

Leave a Reply