It is possible to transfer data from one form to another. Let’s assume we have two forms; Form 1 and Form 2. The general methodology is as follows:
- Form 1 uses a Redirect action that redirects to the URL of Form 2 when the form is submitted. The URL includes a query string which contains the values from Form 1 using the WS Form variable
#field(123)
where 123 is the ID of the field. - Form 2 extracts the values from the query string using the WS Form variable
#query_var("parameter")
. This variable is added to the Default Value setting of the fields on Form 2.
Form 1 – Create a Redirect Action
In this tutorial we’ll create a simple form containing a name and email field.
On Form 1 we create a redirect action:
- When editing your form, click the Actions icon at the top of the page. The Actions sidebar will open on the side of the page.
- Click the Add icon to add a new action.
- Select Redirect from the Action pulldown. A series of settings will appear.
- In the URL setting add the web address to Form 2.
- In the Query String Parameter setting we’re going add two rows, one for Name field and one for the Email field. To add a query string parameter, click the Add icon twice, one for each row, then we’ll enter the following:
Field: n
Value: #field(1)
Field: e
Value: #field(2)
… where 1 is the ID of the Name field and 2 is the ID of the Email field.
NOTE: Certain query string parameters are reserved by WordPress and will cause a redirect or 404 error. Please refer to the list of reserved query parameters here.
An example of configuring the redirect action is shown below:
Form 2 – Set Default Values
On Form 2 you extract the field values from Form 1 using the WS Form variable #query_var("parameter")
in the default value setting of the fields on that form.
In this tutorial we’ll create two corresponding text fields, one labeled Name, the other Email.
To set the default value of the Name text field:
- Click the settings icon on the text field.
- In the Default Value setting we’ll add:
#query_var("n")
. - Click Save & Close.
This will extract the n
parameter from the query string and will replace it with the name entered on Form 1.
We do the same for the Email field using a default value of #query_var("e")
so that it extracts the query string parameter e
instead.
And that’s it. When Form 1 is submitted, the values from the Name and Email fields will be passed to Form 2 and loaded into the corresponding fields.
Some fields, such as Select, Checkbox and Radio fields do not have a default value setting (due to the more advanced selected icons in the data grid). These can be populated using a different method:
Learn more about populating fields using query string parameters:
Fields can also be populated dynamically using custom PHP: