Form Object

Form Object

IntroductionUsagePropertiesBasic PropertiesPost RelatedForm SubmissionAdvanced PropertiesForm JSON

Introduction
The Form object is the main object in Gravity Forms. It contains all properties of a particular form (i.e. form title, fields, notification, scheduling, etc…). This object is available to most of the Gravity Forms hooks.
It is formatted as an associative array (i.e. $form[『title』] retrieves the form title).
Usage
12$form['title']                  //returns the form title$form['fields'][0]['type'];     //returns the type of the first field of the form

Properties
Basic Properties

id integer
The form Id.

title string
The form title

description string
The form description

labelPlacement string
Determines if the field labels are displayed on top of the fields (top_label), besides the fields and aligned to the left (left_label) or besides the fields and aligned to the right (right_label)
Possible values: top_label, left_label, right_label

descriptionPlacement string
Determines if the field description is displayed above the field input (i.e. immediately after the field label) or below the field input.
Possible values: above, below
Note: This setting is only available when labelPlacement is set to 「top_label」. When labelPlacement is not 「top_label」, this setting will always be set to 「below」.

Field Object array
List of all fields that belong to the form

Post Related

useCurrentUserAsAuthor bool
For forms with Post fields, this determines if the post should be created using the current logged in user as the author. 1 to use the current user, 0 otherwise.

postAuthor integer
When useCurrentUserAsAuthor is set to 0, this property contains the user Id that will be used as the Post author.

postCategory integer
Form forms with Post fields, but without a Post Category field, this property determines the default category that the post will be associated with when created.

postContentTemplate string
Template to be used when creating the post content. Field variables (i.e. {Name:3} ) can be added to the template to insert user submitted values into the post content. Only applicable when postContentTemplateEnabled is true

postContentTemplateEnabled bool
Determines if the post template functionality is enabled. When enabled, the post content will be created based on the template specified by postContentTemplate.

postFormat string
For forms with Post fields, determines the format that the Post should be created with.
Possible values: Will vary depending on the formats supported by the current theme.

postStatus string
For forms with Post fields, determines the status that the Post should be created with.
Possible values: draft, pending, publish

postTitleTemplate string
Template to be used when creating the post title. Field variables (i.e. {Name:3} ) can be added to the template to insert user submitted values into the post title. Only applicable when postTitleTemplateEnabled is true

postTitleTemplateEnabled bool
Determines if the post title template functionality is enabled. When enabled, the post title will be created based on the template specified by postTitleTemplate.

Form Submission

confirmation array
Contains the form confirmation settings such as confirmation text or redirect URL

notifications Notifications Object
An associative array containing the properties for all the email notifications which exist for a form.

Advanced Properties

Button array
Contains the form button settings such as the button text or image button source.

cssClass string
Custom CSS class. This class will be added to the

tag.

enableAnimation bool
When enabled, conditional logic hide/show operation will be performed with a jQuery slide animation. Only applicable to forms with conditional logic.

enableHoneypot bool
Specifies if the form has the Honeypot spam-protection feature

limitEntries bool
Specifies if this form has a limit on the number of submissions. 1 if the form limits submissions, 0 otherwise.

limitEntriesCount integer
When limitEntries is set to 1, this property specifies the number of submissions allowed.

limitEntriesMessage string
Message that will be displayed when the maximum number of submissions have been reached

scheduleForm bool
Specifies if this form is scheduled to be displayed only during a certain configured date/time

scheduleStart string
Date in the format (mm/dd/yyyy) that the form will become active/visible

scheduleStartHour integer
Hour (1 to 12) that the form will become active/visible

scheduleStartMinute integer
Minute that the form will become active/visible

scheduleStartAmpm string
「am」 or 「pm」. Applies to scheduleStartHour

scheduleEnd string
Date in the format (mm/dd/yyyy) that the form will become inactive/hidden

scheduleEndHour integer
Hour (1 to 12) that the form will become inactive/hidden

scheduleEndMinute integer
Minute that the form will become inactive/hidden

scheduleEndAmpm string
「am」 or 「pm」. Applies to scheduleEndHour

scheduleMessage string
Message to be displayed when form is no longer available

schedulePendingMessage string
Message to be displayed when form is not yet available

Form JSON
This example shows how a form array would look when formatted as JSON for use by the Gravity Forms CLI Add-On.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071{    "title": "My test form",    "description": "",    "labelPlacement": "top_label",    "descriptionPlacement": "below",    "button": {        "type": "text",        "text": "Submit",        "imageUrl": ""    },    "fields": [{        "type": "text",        "label": "My New Label",        "defaultValue": "Just testing",        "id": "1",        "visibility": "visible",        "formId": "14",        "pageNumber": 1    }, {        "type": "select",        "label": "My Dropdown",        "choices": [{            "text": "Choice 1",            "value": "one"        }, {            "text": "Choice 2",            "value": "two"        }],        "id": "2",        "visibility": "visible",        "formId": "14",        "pageNumber": 1,        "isRequired": false    }],    "version": "2.3-rc-5",    "id": "14",    "useCurrentUserAsAuthor": true,    "postContentTemplateEnabled": false,    "postTitleTemplateEnabled": false,    "postTitleTemplate": "",    "postContentTemplate": "",    "lastPageButton": null,    "pagination": null,    "firstPageCssClass": null,    "is_active": "1",    "date_created": "2018-04-12 16:51:40",    "is_trash": "0",    "notifications": {        "5acf8e9cf2b40": {            "id": "5acf8e9cf2b40",            "to": "{admin_email}",            "name": "Admin Notification",            "event": "form_submission",            "toType": "email",            "subject": "New submission from {form_title}",            "message": "{all_fields}"        }    },    "confirmations": {        "5acf8e9cf310a": {            "id": "5acf8e9cf310a",            "name": "Default Confirmation",            "isDefault": true,            "type": "message",            "message": "Thanks for contacting us! We will get in touch with you shortly.",            "url": "",            "pageId": "",            "queryString": ""        }    }}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注