Dynamically populating Gravity Forms from another form
December 11, 2015 • 3 Min Read
You can now easily send Gravity Forms entry data from one form to another without adding any code! Introducing Easy Passthrough for Gravity Forms.
An often used Gravity Forms workflow is populating a form off the values of another a form. A user visits your site, fills out a form and, upon submission, they are brought to a page with another form that contains fields that they filled out on the previous page. Having the user fill out those form fields again is a very inconvenient experience.
The easiest way to do this out of the box with Gravity Forms is to add query parameters to the confirmation URL so they can be populated in the second form. However, this can sometimes be a clumsy solution as you have to manually update the confirmation each time you add a new field whose value you want brought over to the second form. It can also get out of hand if you have more than a handful of fields that need to be copied.
Luckily, there’s a simpler way to do this.
Step 1: Prepare fields for dynamic population
First, we need to prepare the fields we want to copy the values to and from to be dynamically populated.
In the form editor for both forms, select each field you want to dynamically populate and go to the Advanced tab. Within the Advanced tab, click the checkbox labeled Allow field to be populated dynamically and enter in a parameter name. The parameter name needs to be the same on both forms. For example, if you have an Email Address field on both forms whose values should be the same, set the parameter name on each field to email_address.
Step 2: Setup your confirmation
Next, we need to add a reference point to the confirmation URL to be able to retrieve the entry data.
Visit the confirmation page for your first form. Click the Pass Field Data Via Query String checkbox. In the text box below the checkbox, set the Entry ID to be passed as entry_id:
Step 3: Install the Easy Form Population code snippet
Finally, insert the following snippet either into your functions.php file or as a new file that is included in your functions.php.
Before a Gravity Form is rendered, this snippet checks to see if an entry ID query parameter exists. If it does, it retrieves the entry and pass in any values whose field parameter names match.
Need to transfer entry data between forms with fields that have multiple inputs (Name field, Address field, List field)? Check out Easy Passthrough for Gravity Forms.