Field Object

Field Object

IntroductionUsagePropertiesBasic PropertiesPost FieldsAdvanced FieldsNumberDatePhoneName and AddressFile UploadCAPTCHAOtherPricing FieldsAdd-On FieldsField JSON

Introduction

The Field object contains all settings for a particular field. It is part of the Form Object and is available in most Gravity Forms hooks. It can be manipulated to dynamically change the way the field is displayed.

Usage

12// returns the label of the first field on the form$form['fields'][0]->label;

1234// displays the types of every field in the formforeach ( $form['fields'] as $field ) {   echo $field->type . '
';}

Properties

Basic Properties

adminLabel string When specified, the value of this property will be used on the admin pages instead of the label. It is useful for fields with long labels. Applies to: All fieldsadminOnly bool Determines if this field should only visible on the administration pages. A value of 1 will mark the field as admin only and will hide it from the public form. Useful for fields such as 「status」 that help with managing entries, but don』t apply to users filling out the form. Applies to: All fieldsallowsPrepopulate bool Determines if the field』s value can be pre-populated dynamically. 1 to allow field to be pre-populated, 0 otherwise. Applies to: All fieldschoices array Contains the available choices for the field. For instance, drop down items and checkbox items are configured with this property. Applies to: select, checkbox, radio, post_category

123$choices = $field->choices;$choices[0]['text'] = 'Drop down item 1';$field->choices = $choices;

Each choice in the array has the following Properties:text string The text to be displayed to the user when displaying this choice.value string The value to be stored in the database when this choice is selected. Note: This property is only supported by the Drop Down and Post Category fields. Checkboxes and Radio fields will store the text property in the database regardless of the value propertyisSelected bool Determines if this choice should be selected by default when displayed. The value 1 will select the choice, 0 will display it unselected.Conditional Logic array Controls the visibility of the field based on values selected by the user.content string Content of an HTML block field to be displayed on the form Applies to: htmlcssClass string Custom CSS class to be added to the

  • tag that contains the field. Useful to apply custom formatting to specific fields. Applies to: All fieldsdefaultValue string Contains the default value for the field. When specified, the field』s value will be populated with the contents of this property when the form is displayed. Applies to: hidden, text, website, phone, number, date, textarea, email, post_title, post_content, post_excerpt, post_tags, post_custom_fielddescription string Field description. Applies to: All fieldsenableChoiceValue bool Determines if the field (checkbox, select or radio) have choice values enabled, which allows the field to have choice values different from the labels that are displayed to the user Applies to: checkbox, select and radioerrorMessage string Contains the message that is displayed for fields that fail validation Applies to: All fields except html, section and hiddenid integer Field IdinputName string Assigns a name to this field so that it can be populated dynamically via this input name. Only applicable when allowsPrepopulate is set to 1. Applies to: All fields except section and captchaisRequired bool Determines if the field requires the user to enter a value. 1 marks the field as required, 0 marks the field as not required. Fields marked as required will prevent the form from being submitted if the user has not entered a value in it. Applies to: All fields except section, html and captchalabel string Field label that will be displayed on the form and on the admin pages Applies to: All fieldsnoDuplicates bool Determines if the field allows duplicate submissions. 1 to prevent users from submitting the same value more than once, 0 to allow duplicate values. Applies to: hidden, text, website, phone, number, date, time, textarea, select, radio, email, post_custom_fieldsize string Determines the size of the field when displayed on the page Applies to: All fields except html, section and captchaPossible values: small, medium, largetype string The type of field to be displayed Applies to: All fieldsPossible values: html, hidden, section, text, website, phone, number, date, time, textarea, select, checkbox, radio, name, address, fileupload, email, post_title, post_content, post_excerpt, post_tags, post_category, post_image, post_custom_field, captcha

    Post Fields

    postCustomFieldName string The name of the Post Custom Field that the submitted value should be assigned to. Applies to: post_custom_fielddisplayAllCategories bool Determines if all categories should be displayed on the Post Category drop down. 1 to display all categories, 0 otherwise. If this property is set to 1 (display all categories), the Post Category drop down will display the categories hierarchically. Applies to: post_categorydisplayCaption bool Controls the visibility of the caption metadata for Post Image fields. 1 will display the caption field, 0 will hide it. Applies to: post_imagedisplayDescription bool Controls the visibility of the description metadata for Post Image fields. 1 will display the description field, 0 will hide it. Applies to: post_imagedisplayTitle bool Controls the visibility of the title metadata for Post Image fields. 1 will display the title field, 0 will hide it. Applies to: post_imageinputType string Contains a field type and allows a field type to be displayed as another field type. A good example is the Post Custom Field, that can be displayed as various different types of fields. Applies to: post_custom_field

    Advanced Fields

    Number

    numberFormat string Specifies the format allowed for the number field. Applies to: numberPossible values: decimal_dot, decimal_commadecimal_dot: 9,999.99decimal_comma: 9.999,99rangeMin float Minimum allowed value for a number field. Values lower than the number specified by this property will cause the field to fail validation. Applies to: numberrangeMax float Maximum allowed value for a number field. Values higher than the number specified by this property will cause the field to fail validation. Applies to: number

    Date

    calendarIconType string Determines how the date field displays it』s calendar icon Applies to: datePossible values: calendar, custom, nonecalendar: Displays the standard calendar icon shipped with Gravity Formscustom: Allows administrators to specify a custom iconnone: Disables the calendar iconcalendarIconUrl string Contains the URL to the custom calendar icon. Only applicable when calendarIconType is set to custom Applies to: datedateFormat string Determines how the date is displayed Applies to: datePossible values: mdy, dmymdy: 01/25/2010dmy: 25/01/2010

    Phone

    phoneFormat string Determines the allowed format for phones. If the phone value does not conform with the specified format, the field will fail validation. Applies to: phonePossible values: standard, internationalstandard: Phone must be in the format: 「(###)### – ####」international: Phone can be in any format

    Name and Address

    nameFormat string Determines the format of the name field Applies to: namePossible values: normal, extended, simplenormal: Displays first and last name fieldsextended: Displays prefix, first, last and suffix fieldssimple: Displays one name fieldaddressType stringDetermines the type of address to be displayed.   Applies to: addressPossible values: international, us, canadianinternational: State input is displayed as a text field and the country drop down is displayedus: State input is displayed as a drop down with US states and the country drop down is hiddencanadian: State input is displayed as a drop down with Canadian provinces and the country drop down is hiddendefaultCountry string Contains the country that will be selected by default. Only applicable when addressType is set to international Applies to: addressdefaultProvince string Contains the province that will be selected by default. Only applicable when addressType is set to canadian Applies to: addressdefaultState string Contains the state that will be selected by default. Only applicable when addressType is set to us Applies to: addresshideAddress2 bool Controls the visibility of the address 2 field. A value of 1 will hide the address 2 field, 0 will display it. Applies to: addresshideCountry Controls the visibility of the country drop down. A value of 1 will hide the country drop down, 0 will display it. Only applicable when addressType is set to international Applies to: addresshideState bool Controls the visibility of the state field. A value of 1 will hide the state field, 0 will display it. Applies to: addressinputs array For fields with multiple inputs (i.e. Name, Address), this property contains a list of inputs. This property also applies to the checkbox field as checkboxes are treated as multi-input fields (since each checkbox item is stored separately). Applies to: name, address, checkbox

    1234$inputs = $field->inputs;$inputs[0]['label'] = 'First Name';//sets the label for the first input$field->inputs = $inputs

    Each input has the following properties.id float The input id. Input Ids follow the following naming convention: 「FIELDID.INPUTID」 (i.e. 5.1), where FIELDID is the id of the containing field and INPUTID specifies the input field. For example, inputs for the name field are numbered as follows:FIELDID.2 Name Prefix input id (i.e. 4.2)FIELDID.3 First Name input id (i.e. 4.3)FIELDID.6 Last Name input id (i.e. 4.6)FIELDID.8 Name Suffix input id (i.e. 4.8)label string Input labelname string When the field is configured with allowsPrepopulate set to 1, this property contains the parameter name to be used to populate this field (equivalent to the inputName property of single-input fields)

    File Upload

    allowedExtensions string Contains a comma delimited list of file extensions that are allowed to be uploaded. (i.e. jpg,gif,png) Applies to: fileupload, post_image

    CAPTCHA

    captchaType string Determines the type of CAPTCHA field to be used Possible values: recaptcha, simple_captcha, mathNOTE: simple_captcha and math CAPTCHA fields are only available when the 「Really Simple CAPTCHA」 plugin is installedcaptchaTheme string Determines the theme to be used for the reCAPTCHA field. Only applicable to the recaptcha captcha type. Possible values: red, white, blackglass, cleansimpleCaptchaSize string Determines the CAPTCHA image size. Only applicable to simple_captcha and math captcha types. Possible values: small, medium, largesimpleCaptchaFontColor Determines the image』s font color, in HEX format (i.e. #CCCCCC). Only applicable to simple_captcha and math captcha types.simpleCaptchaBackgroundColor string Determines the image』s background color, in HEX format (i.e. #CCCCCC). Only applicable to simple_captcha and math captcha types.

    Other

    enablePasswordInput bool Determines if a text field input tag should be created with a 『password』 type Applies to: textmaxLength integer Specifies the maximum number of characters allowed in a text or paragraph field.enableEnhancedUI bool When set to true, the Chosen jQuery script will be applied to this field, enabling search capabilities to Drop Down fields and a more user-friendly interface for Multi Select fields. Applies to: select, multiselect

    Pricing Fields

    basePrice float Base price for a single product field. Applies to: singleproductdisableQuantity bool Specifies if the quantity field on single product fields should be displayed or hidden. Applies to: singleproductproductField integer Available only on Option fields. Specifies which product field the current option field is linked to. Applies to: optionenablePrice bool Specifies if a price can be entered for each field choice. This option is automatically turned ON for pricing fields when using Drop Down, Radio Button or Checkbox input types. Applies to: checkbox, select, radio

    Add-On Fields

    See the following pages for details about fields added by add-ons:

    CouponDropbox Upload

    Field JSON

    This example shows how a field object would look when formatted as JSON for use by the Gravity Forms CLI Add-On.

    12345678910111213141516{    "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}

  • Field Types

    Field Types

    The following field types are available when creating settings using the Settings API:

    Dynamic Field Map
    Creates a set of fields that allow the user to map their form fields to custom keys (fields) entered by the user.

    Checkbox
    Creates a checkbox field.

    Checkboxed Select
    Creates a complex field where a hidden drop-down field is displayed when the checkbox is checked.

    Custom Field
    Learn how to create custom field types.

    Field Map
    Creates a set of fields that allow the user to map their form fields to a custom field selected from a predefined list.

    Field Select
    Creates a drop down field populated with fields from the form.

    Generic Map
    Creates a set of fields that allow the user to map custom keys to custom values, based on submission or other data.

    Hidden
    Creates a hidden field.

    Radio Button
    Creates a radio button field.

    Select
    Creates a select/drop-down field.

    Save Button
    Creates a save button.

    Select Custom
    Creates a select/drop-down field which also allows users to enter a custom value.

    Simple Condition
    Creates a complex set of fields allowing users to specify a condition (i.e. Country is Brazil).

    Text
    Creates a text field.

    Textarea
    Creates a textarea field.

    {all_fields} Merge Tag

    {all_fields} Merge Tag

    SummaryUsageModifiers:admin:value:empty:noadmin:nohidden

    Summary
    Displays a preformatted HTML table containing all of the submitted values.
    Usage
    {all_fields}
    {all_fields:[modifier1],[modifier2],[…]}
    Modifiers
    You may append multiple modifiers using comma as a delimiter. They are not order sensitive.
    Examples:
    {all_fields:value,empty}
    {all_fields:admin,value}
    :admin
    Uses the fields』 Admin Labels (if specified) rather than the default field labels.
    Example: {all_fields:admin}
    :value
    Displays the actual value rather than the corresponding value label. This typically applies to fields with multiple inputs such as checkboxes, radio buttons and drop downs.
    Example: {all_fields:value}
    :empty
    Shows fields for which no value was submitted.
    :noadmin
    Hides field output of fields set to a Visibility of Admin Only.
    :nohidden
    Hides field output of fields using the Hidden field type. It doesn』t affect to fields set to a Visibility of Hidden.

    File Upload Field CSS Selectors

    File Upload Field CSS Selectors

    Single File UploadContainerInputMulti-File UploadContainerUpload Instruction TextValidation MessageFile Selection Button

    Single File Upload
    Container
    example: file upload container (div) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload {border: 1px solid red;}
    example: file upload container (div) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload {border: 1px solid red;}
    example: file upload container (div) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload {border: 1px solid red;}
    Input
    example: file upload input (input) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload input {color: red;}
    example: file upload input (input) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload input {color: red;}
    example: file upload input (input) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload input {color: red;}
    Multi-File Upload
    Container
    example: multi-file upload container (div) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload {border: 1px solid red;}
    example: multi-file upload container (div) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload {border: 1px solid red;}
    example: multi-file upload container (div) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload {border: 1px solid red;}
    Upload Instruction Text
    example: file upload container (span) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload .gform_drop_instructions {color: red;}
    example: file upload container (span) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload .gform_drop_instructions {color: red;}
    example: file upload container (span) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload .gform_drop_instructions {color: red;}
    Validation Message
    example: file upload validation message (div) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload .validation_message {color: red;}
    example: file upload validation message (div) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload .validation_message {color: red;}
    example: file upload validation message (div) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload .validation_message {color: red;}
    File Selection Button
    example: file selection button (input) – applies to all forms
    1body .gform_wrapper .gform_body .gform_fields .gfield .ginput_container_fileupload .gform_button_select_files {color: red;}
    example: file selection button (input) – applies just to form ID #1
    1body .gform_wrapper_1 .gform_body .gform_fields .gfield .ginput_container_fileupload .gform_button_select_files {color: red;}
    example: file selection button (input) – applies just to specific container (based on the unique parent element ID – replace 「XX_X」 with your actual element ID)
    1body .gform_wrapper_1 .gform_body .gform_fields #field_XX_X.gfield .ginput_container_fileupload .gform_button_select_files {color: red;}

    File Upload

    File Upload

    SummaryCommon SettingsGeneral SettingsNotesMerge TagsUsageModifiers

    Summary

    The File Upload field allows users to upload a file with their form submission. You may limit which filetypes a user may upload via the properties tab. It is available under the Advanced Fields section within the form editor.

    File Upload field as displayed in the Field Library

    File Upload field as displayed in the Form editor

    Common Settings

    This field uses only common field settings for the Appearance and Advanced settings. For a description of each of the common field settings, refer to this article. Below you will find description of specialty settings that are particular to this field.

    General Settings

    SettingsDescriptionAllowed file extensionsEnter the allowed file extensions for file uploads. This will limit what type of files a user may upload. See note 1.Enable Multi-File UploadIf checked, this option allows the user to upload multiple files. If unchecked (default state), the upload will accept only a single file. See note 2.Maximum File SizeUse this to specify the maximum size in megabytes allowed for each of the files.

    Notes

    1. See this article for important notes on WordPress permitted file types.2. Once an entry has been submitted using this field, this option will no longer be editable. That is, you cannot switch a file upload field from from single file to multi-file once an entry with a file has been submitted.

    Merge Tags

    For more information on the use of merge tags, refer to these articles.

    Usage

    {Field Name:2:modifier}

    Modifiers

    ModifiersDescription:downloadDenotes that the link created for the download should force the download when accessed.

    Finding Your Gravity Forms Account

    Finding Your Gravity Forms Account

    IntroductionFinding A Gravity Forms AccountI think I remember the account email…I have no clue as to what the account email might be…I used an agency or contractor to setup my website, and they never gave me the license

    Introduction

    Sometimes you may find you have a Gravity Forms license key in use on your site, but do not know or cannot remember exactly which Gravity Forms account that owns it. This stops you from logging in and performing account management operations like updating a payment method, as well as some license operations such as reviewing your site list or canceling an auto-renewal.

    There are a couple of approaches you can use to try and find out the Gravity Forms account.

    Finding A Gravity Forms Account

    The approach to finding an account depends on what information you have.

    IMPORTANT NOTE: we can not always identify a third party owner to you due to our privacy policies related to customer data.

    Using a Gravity Forms license key on your website does not mean you have a right to the Gravity Forms account that holds that license key. The account owner is defined as the owner of the email address the account is held under, and identifying information can only be provided to that validated user in most circumstances.

    I think I remember the account email…

    If you have a few commonly used email addresses for sign-ups, then try using the Password Reset functionality on our Gravity Forms account page to see if the account exists.

    You can request a password reset email here: https://www.gravityforms.com/wp-login.php?action=lostpassword

    Don』t forget to check your Bulk or Spam folders. Password Reset emails often trigger spam checks and result in your legitimate request being dumped into an unseen Bulk or Suspicious folder by your email service.

    Once you have reset the password and logged in you』ll be able to view your profile, licenses, and access the downloads here: https://www.gravityforms.com/my-account/

    I have no clue as to what the account email might be…

    You may have inherited the website with Gravity Forms installed from a previous employee, design agency or third party. This might mean that you have no idea what email address the account is held under.

    We can search for your license key using some key data, and then identify the holding account.

    To try and locate the owning account, reach out to the General Questions support channel for assistance, and provide some of the following information.

    If you know the license only from the website it is on:

    Provide the URL of the website where you think the license is in use

    If you know the license key number:

    Provide the license key to us.

    If you know only the charge on your credit card, the provide us the following transaction details:

    Payment method details (e.g. PayPal account email or last 4 digits of credit card used) Date of the transaction. Amount of the transactionFull Name on the Credit or Debit Card

    From there we can try to find the account by working backwards from the transaction.

    I used an agency or contractor to setup my website, and they never gave me the license

    If you know the license is owned by a third party, then you will have to reach out to them directly. Only the account owner can perform certain operations, such as requesting technical support, or transferring the license to you.

    If you have no recollection of who you used, or no method to contact the site developer you think probably holds the license key, then we recommend you purchase a new license and register it on your site. This can be done without any disruption to your forms or form data, and is the only way to guarantee you have full control over your key moving forward.

    You can purchase on our website. Be sure to obtain the license type that has access to all the add-ons and meets the site count you require. For a quick comparison of license types, see this help guide.

    Forcing Gravity Forms Database Upgrades

    Forcing Gravity Forms Database Upgrades

    If you』re having issues upgrading the Gravity Forms database after an update, this can sometimes be due to a failed database modification. Often times, forcing the database upgrade can resolve the issue. Attempting to do a manual upgrade is not recommended and this method should be followed. Here』s how to force a Gravity Forms database upgrade.

    Before making any changes, it』s always a good idea to backup your database. If you』re not sure how to do so, contact your web hosting provider.Within your WordPress admin dashboard, hover over Forms and click on System Status.Scroll down to the Database section and click on Re-run database upgrade.

    Your database upgrade should now be complete.

    If you are getting repeated upgrade issues, contact our support team for expert technical advice.

    The System Status page, showing the database upgrade option.