TutorialGravity Forms Inception – Building a Form with a Form

With Gravity Forms in combination with some Add-ons, you can create a form to create another form. This can be particularly handy when you have a solid structure for a form, but the only difference is the questions you ask. There is a way to accomplish that without the need to code yourself. We’ll walk you through step by step.

Building a Form with a Form without programming

One way to go is using the Preview Submission Add-on from GravityWiz. This Add-on makes it possible to fill in data from previous steps in your Form as default value of an input field or as content for a HTML-block. That’s what we’re going to need to create our Form based on another Form.

First, we have to determine what the structure is going to be for our final Form. For this example, we’re going to make an Evaluation Form Format with some Radio Buttons with fixed choices and open questions. For that we need the following fields:

  • Title Evaluation
  • Introduction text
  • Number of Radio Button choice questions (1 – 3)
  • Label Radio Button 1 – Score – Terrible | Not so great | Neutral | Pretty good | Excellent
  • Label Radio Button 2 – Score – Terrible | Not so great | Neutral | Pretty good | Excellent
  • Label Radio Button 3 – Score – Terrible | Not so great | Neutral | Pretty good | Excellent
  • Number of open questions (1 -2)
  • Label open question 1
  • Label open question 2

What Add-ons do you need?

You need Gravity Forms, the Preview Submission Perk and the Populate Anything Perk to get this working.

Configuring the Gravity Forms Format Form

First we add a Single Line Text field and a Paragraph Text to capture the Title of the Evaluation and the introduction text and make them required.

Screenshot Gravity Forms Format Form beginning
Screenshot Gravity Forms Format Form beginning

Then we add a Drop Down with choices 1, 2 and 3, so you can select how many Radio Button Score questions you want to show. We add Single Line Text fields for every label we need for the scoring questions.

Screenshot Drop Down Field to select how many Radio Buttons you want to show.
Screenshot Drop Down Field to select how many Radio Buttons you want to show.

We set conditional logic based on the value of the Number of Radio button choice questions. See here for example the conditional logic applied to Label Radio Button 3 – Score field. We only want to show this Single Line Text field if the choice is higher than 2.

Screenshot of Conditional Logic on the Single Line Text fields.
Screenshot of Conditional Logic on the Single Line Text fields.

The same we do for the 1 or 2 open question labels, including the same conditional logic, but now on the Number of open questions dropdown value.

Screenshot of setting Conditional Logic on the labels.
Screenshot of setting Conditional Logic on the labels.

Using the Format Form to create another Form

After configuring your Format Form, you can start building the Evaluation Form for your website visitors, based on an Entry from the Format Form.

For creating the form, we have to have fields to capture the ‘settings’ from the Entry in the Format Form. We do that by adding fields to our Dynamic Form and make the visibility Hidden. We also need to give them a Parameter Name, since we want to be able to populate these fields from our url.

See here for example a screenshot of the Title Evaluation field, with visibility set to Hidden and as Parameter name ‘title-evaluation’.

Screenshot of the Form we want to Dynamically generate, setting the Dynamic Population parameter.
Screenshot of the Form we want to Dynamically generate, setting the Dynamic Population parameter.

We also need a number field (or you can also use the dropdown, but this is not necessary, because you just want to know a number) for the Number of Radio button choice questions:

Screenshot of adding the Number Field to know how many Radio Buttons we have to show.
Screenshot of adding the Number Field to know how many Radio Buttons we have to show.

And als the Label for each radio button, with conditional logic configured based on the Number Field:

Screenshot of adding a Question Label Single Line Text field.
Screenshot of adding a Question Label.

Showing the Form Questions with HTML-blocks

We now have a lot of invisible fields with data in it (populated by the url, the Save and Continue link, the JWT token or through the Gravity Forms shortcode), but the front-end visitor of the Form doesn’t see anything yet. To get that working, we need to add HTML-blocks with data from populated fields in our Form. You can do that with Preview Submission (you need multiple steps in your form) or with Live Merge Tags (included in the Populate Anything Add-on). We will show in this example the Live Merge Tags. You can use Preview Submission in the same way, but you have to place all the fields you dynamically populate with hidden visibility on the first page of your form and the rest of the HTML Blocks and input fields on the second page. This requires a click on the ‘Next’ button to work.

Live Merge Tags (Populate Anything)

With Populate Anything activated, you can use Live Merge Tags inside your HTML Blocks (and standard values) by adding the @ sign before the Merge Tag. See this example where we show the title of the Evaluation in heading 1 by using the following code:

<h1>@{Title Evaluation:2}</h1>
Screenshot of Live Merge Tags to show the Title of the Dynamic Form.
Screenshot of Live Merge Tags to show the Title of the Dynamic Form.

For the questions themselves, we also add a HTML Block for the Question label and a Radio Button to capture the actual input for that question. On both fields we activate Conditional Logic and show it depended on the number of questions we want to show:

Screenshot of the HTML Block to show the Question Label of Radio Button field 1.
Screenshot of the HTML Block to show the Question Label of Radio Button field 1.

We show the question in the HTML Block as a strong text, again with a Live Merge Tag (adding the @ sign before the Merge Tag):

<strong>@{Label Radio Button 1 - Score:5}</strong>

And the Radio Button choice we give a label ‘Radio Button 1’, but we hide the Label itself, because we use the HTML Block above it to show the dynamically loaded question label.

Screenshot of setting the Label on Hidden, since we show the Label in a HTML Block.
Screenshot of setting the Label on Hidden, since we show the Label in a HTML Block.

We do the same for the other Radio Buttons and for the Open Questions. Make sure that for the Open Questions you set the conditional logic based on the Number Field where the number of Open Questions is filled in.

For the Open Questions we use a Paragraph Text:

Screenshot of setting conditional logic on our input field (in this case the Paragraph Text field for the Open Question 1).
Screenshot of setting conditional logic on our input field (in this case the Paragraph Text field for the Open Question 1).

Populating the Form Questions

We now have these fields availble to populate:

Field LabelPopulateField Type
Title Evaluationtitle-evaluationtext
Introduction textintroduction-texttextarea
Number of Radio button choice questionsnumber-radio-buttonnumber
Label Radio Button 1 – Scorelabel-radio-button-1text
Label Radio Button 2 – Scorelabel-radio-button-2text
Label Radio Button 3 – Scorelabel-radio-button-3text
Number of open questionsnumber-open-questionsnumber
Label open question 1label-open-question-1text
Label open question 2label-open-question-1text
Table with the fields we can dynamically populate, the Dynamic Population slug and the Type of Gravity Forms Field.

We use our GravityWP – Merge Tags Add-on to get a quick overview of fields and dynamic populate slugs and generate a url we can use to create our other Form:

Screenshot of GravityWP - Merge Tags, the Advanced Tab including the url with Dynamic Population parameters we need.
Screenshot of GravityWP – Merge Tags, the Advanced Tab including the url with Dynamic Population parameters we need.

We can easily copy the url on the bottom of the Advanced Tab to use for dynamic population:

/?title-evaluation=MERGETAG&introduction-text=MERGETAG&number-radio-button=MERGETAG&label-radio-button-1=MERGETAG&label-radio-button-2=MERGETAG&label-radio-button-3=MERGETAG&number-open-questions=MERGETAG&label-open-question-1=MERGETAG&label-open-question-2=MERGETAG

And we create a url filled with Merge Tags from our Format Form:

/?title-evaluation={Title Evaluation:6}&introduction-text={Introduction text:1}&number-radio-button={Number of Radio button choice questions:2}&label-radio-button-1={Label Radio Button 1 - Score:3}&label-radio-button-2={Label Radio Button 2 - Score:4}&label-radio-button-3={Label Radio Button 3 - Score:5}&number-open-questions={Number of open questions:7}&label-open-question-1={Label open question 1:8}&label-open-question-2={Label open question 2:9}

We can use this url later on places where we want to communicate a link to our dynamically generated form based on data from the Entry in the Format Form.

Notice that there are quite some texts being included in the url. It can be that if there are certain characters in the url that the link will not work correctly. That’s why it’s always better to urlencode the Merge Tags you use inside a url.

A quick way to do that is by using our Advanced Merge Tags Add-on for Gravity Forms. You can easily use the gwp_urlencode modifier to automatically urlencode the output. The code we use than to generate the url will look like this:

/?title-evaluation={Title Evaluation:6:gwp_urlencode}&introduction-text={Introduction text:1:gwp_urlencode}&number-radio-button={Number of Radio button choice questions:2}&label-radio-button-1={Label Radio Button 1 - Score:3:gwp_urlencode}&label-radio-button-2={Label Radio Button 2 - Score:4:gwp_urlencode}&label-radio-button-3={Label Radio Button 3 - Score:5:gwp_urlencode}&number-open-questions={Number of open questions:7}&label-open-question-1={Label open question 1:8:gwp_urlencode}&label-open-question-2={Label open question 2:9:gwp_urlencode}

We can now be assured that the url will work correctly.

Dynamic Form based on an Entry in Format Form

Imagine we have an entry in our Format Form with these values:

Field Value
Title EvaluationEvaluation Tutorial Form Inception
Introduction textThis is an example Form generated on basis of data from an Entry in the Format Form.
Number of Radio button choice questions3
Label Radio Button 1 – ScoreWhat did you think about the structure of the Tutorial?
Label Radio Button 2 – ScoreWhat do you think about the idea of creating a Form with a Form?
Label Radio Button 3 – ScoreWhat do you think about our Gravity Forms Tutorials in general?
Number of open questions2
Label open question 1What didn’t you like about the Tutorial? Do you have any suggestions for improvement?
Label open question 2What did you like about the Tutorial? Share any positive insights you got from reading it.
Table with example Entry data for the Format Form, what we will use to create our Dynamic Form.

The above values in the Format Form will result in the following url:

/?title-evaluation=Evaluation+Tutorial+Form+Inception&introduction-text=This+is+an+example+Form+generated+on+basis+of+data+from+an+Entry+in+the+Format+Form.&number-radio-button=3&label-radio-button-1=What+did+you+think+about+the+structure+of+the+Tutorial%3F&label-radio-button-2=What+do+you+think+about+the+idea+of+creating+a+Form+with+a+Form%3F&label-radio-button-3=What+do+you+think+about+our+Gravity+Forms+Tutorials+in+general%3F&number-open-questions=2&label-open-question-1=What+didn%26%23039%3Bt+you+like+about+the+Tutorial%3F+Do+you+have+any+suggestions+for+improvement%3F&label-open-question-2=What+did+you+like+about+the+Tutorial%3F+Share+any+positive+insights+you+got+from+reading+it.

We have to embed the Dynamic Form on a page to get it working. You can check the above link for this Tutorial by clicking the button below:

Try it yourself

You can also try it yourself. Just fill in some questions and click Next to generate a URL to use.

Embedding with Gravity Forms Shortcode

You can also use the values from the Format Form Entry to create a Gravity Forms Shortcode that you directly embed on a page. This way it’s more difficult for visitors to change the data by simply changing data in the url. The shortcode for our example looks like this:

[gravityform id="1" title="false" description="false" ajax="true" tabindex="1" field_values="title-evaluation=Evaluation+Tutorial+Form+Inception&introduction-text=This+is+an+example+Form+generated+on+basis+of+data+from+an+Entry+in+the+Format+Form.&number-radio-button=3&label-radio-button-1=What+did+you+think+about+the+structure+of+the+Tutorial%3F&label-radio-button-2=What+do+you+think+about+the+idea+of+creating+a+Form+with+a+Form%3F&label-radio-button-3=What+do+you+think+about+our+Gravity+Forms+Tutorials+in+general%3F&number-open-questions=2&label-open-question-1=What+didn%26%23039%3Bt+you+like+about+the+Tutorial%3F+Do+you+have+any+suggestions+for+improvement%3F&label-open-question-2=What+did+you+like+about+the+Tutorial%3F+Share+any+positive+insights+you+got+from+reading+it."]

FAQ Building a Form with a Form

Can I create a Gravity Form based on an Entry in another Gravity Form?

Yes, you can dynamically create questions for a Gravity Form based on values from another (base / format) Form. It has some limitations if you want to do that without any programming, but in cases where you have a solid Form structure and the only thing that changes are the question labels, it’s possible to create a Form based on another Form.

Does this Tutorial explain how to create a new Gravity Form with a new Form ID?

No, in this Tutorial we will explain you how you can build a Form where the question labels are displayed dynamically based on the values from another Form. We don’t actually create a new Form (with new Form ID). This is also possible, but only programmatically.

Why is it useful to be able to create a Form based on the Entry in another Form?

In cases where the answer structure is not changing, but you only want to ask different questions, there is no need to create for every Form a complete new Form. In stead, you can also use one Form (we call it Format Form in this Tutorial) to fill in the Question Labels and another Form (we call it Dynamic Form) to use the Entry data from the Format Form to fill in the questions in the Dynamic Form.

Read more tutorials about Gravity Wiz LLC

Gravity Perks by Gravity Wiz LLC provides you with extra, very handy options and functionalities for your Gravity Forms. Visit GravityWiz.com
All tutorials Gravity Wiz LLC