Building Nested Forms with Gravity Forms
Nested forms allow you to create complex, multi-level form structures where users can submit multiple related entries within a single form submission. This powerful feature is perfect for scenarios where you need to collect a parent record along with multiple child records.
What Are Nested Forms?
Nested forms enable you to embed one form (child form) inside another form (parent form), creating a one-to-many relationship between form entries. When a user submits the parent form, it can contain multiple instances of the child form, all processed as a single transaction.
Common Use Cases:
- Event registration with multiple attendees
- Product orders with multiple line items
- Survey responses with multiple participants
- Course enrollment with multiple students
- VBS registration with multiple children (our example)
How Nested Forms Work
Architecture Overview
- Parent Form - Contains the main record information and houses the nested form field
- Child Form - The embedded form that can be filled out multiple times
- Nested Form Field - A special field type that connects the two forms
- Data Relationship - Parent entries contain references to multiple child entries
Key Features
- Dynamic Entry Creation: Users can add/remove child form instances as needed
- Field Population: Child forms can access parent form data via merge tags
- Calculation Integration: Child form totals can be calculated into parent form fields
- Conditional Logic: Both parent and child forms support full conditional logic
- Notification Flexibility: Separate notifications for parent and child form submissions
Data Flow
- User fills out parent form fields
- User adds one or more child form entries
- Child form data can reference parent form fields (like email addresses)
- Calculations from child forms feed back into parent form totals
- Single submission creates one parent entry with multiple linked child entries
Example: VBS Family Registration
Throughout this guide, we'll build a Vacation Bible School (VBS) registration system that demonstrates these concepts. Our example will include:
- Parent Form: Family information and contact details
- Child Form: Individual child registration with age-based pricing
- Advanced Features: Variable pricing, conditional logic, automated notifications, and payment integration
Prerequisites
Before setting up your VBS registration forms, ensure you have:
- Gravity Forms plugin installed and activated
- GP Nested Forms perk from Gravity Wiz
- GP Conditional Pricing perk (for variable pricing examples)
- Basic understanding of Gravity Forms field types and conditional logic
Implementation Example: VBS Registration System
We'll create a two-form nested system that demonstrates core nested form concepts:
- VBS Child Registration (Child Form) - Individual child records with conditional pricing
- VBS Family Registration (Parent Form) - Parent record that embeds the child form for multiple submissions
Key Features
- Register multiple children in a single form submission
- Variable pricing based on age groups (Preschool-2nd Grade: $25, 3rd-5th Grade: $40)
- Automatic total calculation in the parent form
- Individual confirmation emails for each child registration
- Family summary notification to administrators
Step 1: Building the Child Form
The child form represents the "many" side of our one-to-many relationship. This form will be embedded within the parent form and can be filled out multiple times.
Child Form Setup: VBS Child Registration
First, we'll create the child form that will capture individual child information and pricing.
Basic Child Information Fields
-
Child's Full Name (Name Field)
- Field Label: "Child's Full Name"
- Required: Yes
-
Child Age Group (Radio Button Field)
- Field Label: "Child Age Group"
- Required: Yes
- Options:
- Preschool
- Kindergarten
- 1st Grade
- 2nd Grade
- 3rd Grade
- 4th Grade
- 5th Grade
-
Parent Email (Email Field) - Field Population Example
- Field Label: "Parent Email"
- Required: Yes
- Default Value:
{Parent:3}(assuming field ID 3 is the parent email on the family form) - Description: "This will be populated from the family form automatically"
Nested Forms Concept: Child forms can access parent form field values using the
{Parent:FieldID}merge tag. This enables data sharing between the parent and child forms. -
Special Needs/Allergies (Textarea Field)
- Field Label: "Special Needs, Allergies, or Medical Information"
- Required: No