November 9, 2020: Added support for excluding specific inputs of multi-input fields via the
:exclude
modifier.November 3, 2020: Migrated snippet to the Snippet Library.
January 27, 2020: Added
:nopricingfields
modifier to hide pricing fields from{all_fields}
output.September 5, 2019: Fixed notices generated in PHP7.3 by
continue
statements inside a foreach/switch.April 11, 2019: Updated priority of template replacement to avoid conflict with other merge tags replacement plugins.
The Gravity Forms {all_fields}
merge tag provides a super simple way to output all of the submitted form data but it’s notoriously difficult to customize.
This plugin provides templating support for the {all_fields}
merge tag. Huh? It means you can replace the markup generated by the merge tag with the contents of a file. This tutorial offers a solid starter template file too!
Getting Started
This tutorial assumes you’re running a recent version of Gravity Forms, that you already have the {all_fields}
merge tag implemented wherever you want, and that you ♥ Gravity Wiz.
![]() |
Download, install, and activate the plugin. |
![]() |
Download the sample template directory/file. Add the folder to your active theme’s root directory: /wp-content/themes/{your-theme}/
|
![]() |
Customize the template as desired. |
Template and Merge Tag Options
This plugin provides a few handy modifiers for controlling which template will be used to render the {all_fields}
merge tag.
Note: All template paths are relative to your theme’s root directory.
Default Templates
Merge Tag | Template |
---|---|
{all_fields} | /gravity-forms/all-fields.php |
Form-specific Template
Providing a form-specific template requires not changes to the merge tag. Simply append the targeted form ID to your template’s name. This template will now only be used with the merge tag is used in the context of the specified form.
Merge Tag | Template |
---|---|
{all_fields} | /gravity-forms/all-fields.php /gravity-forms/all-fields-1.php |
Custom Template
You may want to create a custom template that should only be applied to specific instances of the merge tag. The “template” modifier allows you to specify a custom template suffix.
Merge Tag | Template |
---|---|
{all_fields:template[custom]} | /gravity-forms/all-fields-{template}.php /gravity-forms/all-fields-custom.php |
No Template
You may want to create a generic template that applies to all instances of the merge tag by default and then disable that template to use the default Gravity Forms merge tag output in a few specific instances.
Merge Tag | Template |
---|---|
{all_fields:notemplate} | No template |
Hide Pricing Fields
Hide pricing fields (i.e. order summary) from the {all_fields}
output.
Merge Tag | Template |
---|---|
{all_fields:nopricingfields} | Hide pricing fields |
Field Filtering Modifier
These modifiers allow you to control which fields are output in the {all_fields}
merge tag without having to touch any code.
Please note: you only need the plugin installed to use these modifiers. You do not need to install the template files in your theme.
Merge Tag | Description |
---|---|
{all_fields:include[1,2]} | Include a field that is not included by default (i.e. HTML fields). |
{all_fields:exclude[3,4]} | Exclude a field that is included by default. |
{all_fields:filter[1,2]} | Only include the specified field IDs. This takes precedence over both the ‘include’ and ‘exclude’ modifiers. |
{all_fields:include[1,2],exclude[3]} | The :include and :exclude modifiers can be combined. |
GF Nested Forms Support
To filter which fields from a child form display in your {all_fields}
merge tag you can use the :filter modifier and the [Nested Form Field ID].[Child Field ID] format (e.g., 4.3; where 4 is the Nested Form field ID and 3 is the child field ID from the child form).
You can use the :include, :exclude, :filter, and :index modifiers on the Nested Form field to filter which child fields should be displayed.
Merge Tag | Description |
---|---|
{all_fields:filter[1,2,3.4,3.5]} | In this example, 1 and 2 are field IDs on the parent form. 3 is the Nested Form Field ID and 4 and 5 are field IDs on the child form. |
{Nested Form:1:filter[4,5]} | Show fields 4 and 5 from the child form for this Nested Form field. |
{Nested Form:1:index[0],filter[1]} | Show field 1 in the first child entry from the child form. :index must be paired with :filter. |
{Nested Form:1:index[-1],filter[1]}
to target the last entry and display the value from field 1.Excluding Specific Inputs Within a Field
Fields that contain multiple inputs, such as the Name field, can be excluded per-input by specifying the input ID. For example, to exclude the First Name, add .3
to the Field ID (e.g., 5.3; where 5 is the Name field).
This works for any field that contains multiple inputs, such as Name, Address, and Product. You can find the specific input IDs in Gravity Forms Documentation for Name and Address fields.
Merge Tag | Description |
---|---|
{all_fields:exclude[5.3]} | In this example, 5 is the field ID of a Name field. 3 is the First Name input ID. |
Customizing the Template
Ok, don’t let this section intimidate you. Here’s the TLDR; Loop through $items
, use $item['label']
for the field label, and $item['value']
for the field value. Here’s the simplest template you could have:
<ul>
<?php foreach( $items as $item ): ?>
<li>
<strong><?php echo $item['label']; ?><strong><br>
<?php echo $item['value']; ?>
</li>
<?php endforeach; ?>
</ul>
You’ll most likely want to use the sample template above as a starting point though as it takes care of a requirements to better align the template with Gravity Forms default All Fields functionality.
Digging Deeper
The {all_fields}
template works like any other WordPress template with one exception. There is a special $items
array available to you.
Each $item
contains a label, value, and field property. The label and value are the exact label and value that the default {all_fields}
merge tag would output. The field is the input-type-specific GF_Field object for the current field. This is useful when you want to alter the way a field is displayed depending on the field you’re working with.
Lastly, you have access to the current entry via the $entry
variable and the current form via the $form
variable. For more details on these variables, see the parameters section below.
Parameters
$items array
An array of items, each item containing the Gravity-Forms-formatted field label, field value and field object for the given field. The field label and field value are the same values that Gravity Forms outputs in the default
{all_fields}
merge tag.$entry Entry Object
The current Gravity Forms Entry object.
$form Form Object
The current Gravity Forms Form object.
FAQs
How do I hide hidden fields from the {all_fields} merge tag?
You can use the :nohidden
merge tag modifier on the merge tag like this:
{all_fields:nohidden}
Questions? Feedback?
What questions do you have? What features are missing? We’d like to make this into a more robust plugin and your feedback will be a big part of shaping the final product.
Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.
Would this allow me to export my form’s HTML blocks in my notification emails?
Hi Amanda,
Yes, the snippet can allow you to display the HTML blocks within notifications. Once you have the snippet installed, you should be able to use the “include” modifier to output the HTML fields in notifications. The include modifier is written in this format, {all_fields:include[1,2]}, where 1 and 2 are the IDs of the HTML fields you want to include in the notifications.
Best,
I would just love to see notification-email content wihtout the labels of the form fields or without the blue bars in the mail-notification.
Isn’t that possible even without this plugin?
Hello Karl, this is a great question. The all fields template will allow you to take over what is displayed when using the all fields merge tag. You can choose to display value only and not the label. As for blue bars, I am not sure I follow. If you mean each section that is shown and the css behind it , you can customize this within the custom templates we provided. 🙂