In this tutorial, I’ll show you a few ways to create field groups within Gravity Forms that could be reused when populating a form. You might hear these types of fields referred to as repeater fields.
Use Case Example
Let’s assume you’re building a registration form allowing the user to register multiple people in one form; you will likely want to collect the same user information for each registered person. In this case, you will need fields like name, email, phone, age, t-shirt size, etc.
What You’ll Need
What you actually need will vary depending on which of the solutions presented below you decide to go with.
- Gravity Forms (any license type)
- Collapsible Sections Add-On (optional)
- Nested Forms Add-On (optional)
- Repeater Field Doc (optional)
What’s Covered in This Tutorial
There may be more than three or four ways to approach this, but I will demonstrate three options, and you can choose which is ideal for your specific use case.
This is the original question from a Gravity Forms user that sparked the need for this tutorial:
I need to create a form that has a group of fields that give the user the ability to reuse those same fields in the form. For example, if I need to collect contact information from more than one person.
Option One: Only Gravity Forms
In this section, I’ll be demonstrating a solution that only requires Gravity Forms core functionality, no add-ons needed.
This method uses the section break field to create the groups and handle the conditional logic settings for all the fields within that section.
Pro Tip
Building the Form
Let’s build a multi-person event registration form. These are the fields we’re going to need:
- Number
- Section
- Name
- Phone
- Age
- T-Shirt Size
- Food Preference
And we’re going to need those fields repeated for each person being registered.
To make this work, we’re going to create several sections within the form, duplicating the fields in each section. We will then use the number field to determine how many participants we’re registering for this event. Finally, we will add conditional logic to each section field to show/hide the field groups based on the number of participants registering.
For simplicity, I will be limiting the number of participants that can be registered at a time to three.
Watch the demo to see the magic
Pro Tip
Option Two: Collapsible Sections
This is an add-on provided by the third party developer Jetsloth called Collapsible Sections.
In this demonstration, I will use the same form from option one above. The only change will be adding a couple more section fields, and enabling the features provided by this add-on.
The biggest advantage of using the Collapsible Sections add-on is aesthetics. This will present your groups in a contained area, making them appear more like a group.
Watch the demo to see the magic
Pro Tip
If you decide to purchase this add-on, I recommend taking the bundle savings because all of the Jetsloth add-ons are worth having!
Option Three: Nested Forms
This option includes the use of another add-on, this one from Gravity Wiz called Nested Forms.
We will again be using the same form as the first option. However, we will also need a second form.
Using this add-on is a different way of grouping fields in Gravity Forms, but it presents a pretty slick solution.
Watch the demo to see the magic
Option Four: Repeater Field
This is a beta concept provided by Gravity Forms, and while it is the perfect solution for creating groups of repeater fields, it may not be the best solution right now, for two reasons.
- It’s still in beta, and they do not advise using it on production sites.
- There is no user interface, so it requires a bit of custom coding.
They have very detailed documentation on this Repeater feature, so you can find the details here if you want to give it a go.
I will not, however, be demonstrating this solution in this tutorial; I just wanted to make you aware of it.
The Wrap Up
There is proof that you can group fields together in Gravity Forms. And hopefully, one of the three solutions will work for you.
While option one, just using Gravity Forms built-in features, will work and save you some money, depending on how many field groups you need, your form can get bloated and slow.
If you need several repeater fields within your group and the ability to allow a large number of entries, your best option is to use the Nested Forms add-on.
As always, if you have questions or need help, feel free to use the comments below.