Creating a Form Shortcode

Creating a Form Shortcode

SummaryBut I Just Want To Add A Form!Example Form ShortcodeParametersHow To Find The Form IDAdding a Shortcode Using the Shortcode BlockPossible ErrorsShortcode Actions

Summary
WordPress shortcodes allow users to perform certain actions as well as display predefined items within WordPress pages and posts. The Gravity Forms form shortcode is the primary method used to display a Gravity Form on your site.
The form shortcode can be used anywhere within WordPress where shortcodes are supported. For most users, this will primarily be within the content of a WordPress post or page. Shortcodes are added when you use a standard WordPress editor to add the form to the page. Refer to the next section below if you just want further information on adding a form to your site.
But I Just Want To Add A Form!
The information contained here is not needed to add a form to your site, as the standard Add Form functions contained within the page editor will construct the shortcode for you without any manual editing required. This article is just a handy explainer for those curious as to what these shortcodes mean. If you simply want information on the process of adding a form to your post or page, refer to this documentation section.
Example Form Shortcode
1[gravityform id="1" title="false" description="false" ajax="true" tabindex="49" field_values="check=First Choice,Second Choice"]
Parameters
The following parameters are shown within the sample shortcode above.

id
The id of the form to be embedded. (required)
title
Whether or not to display the form title. Defaults to 『true』. (optional)
description
Whether or not to display the form description. Defaults to 『true』. (optional)
ajax
Specify whether or not to use AJAX to submit the form.
tabindex
Specify the starting tab index for the fields of this form.
field_values
Specify the default field values. See also this article for detailed information on dynamic population.

How To Find The Form ID
In order to use a form shortcode, you will need the form ID. Here is how you can determine the ID of your form:

Log into your WordPress admin dashboard.
On the left side navigation menu, hover over Forms and click on Forms.
Find the form you need the ID for, and click on it.
The form ID is listed to the right of the form name.

Adding a Shortcode Using the Shortcode Block
If you are using the WP5+ block editor, and want to add a form using the shortcode instead of the Gravity Forms block, there is actually a Shortcode block (under the Widgets category), which once added will accept a standard Gravity Forms shortcode.
To do this, follow these steps:

Note the form ID of the form you wish to insert on the page.
Within the new block-based editor, bring up the (+) or 「add new block」 dialog where you would like to position it on the page.
Use the search bar to find the Shortcode block and add it. See screenshot.
Insert a valid Gravity Forms shortcode inside the shortcode block. Don』t forget to add the specific form ID you noted within the id=X argument. See screenshot.
Preview your form, and make sure everything checks out!

Possible Errors
If you use the id for a form that does not exist, the following message will be displayed:
1Oops! We could not locate your form.
Shortcode Actions
Other plug-ins can extend the abilities of your Gravity Forms shortcode. Refer to this article for information on additional shortcode functionality that comes with our official User Registration plugin.

發表回覆

您的電子郵箱地址不會被公開。 必填項已用 * 標註