Skip to main content

GF_Field

Class GF_Field

This class provides the base functionality for developers when creating new fields for Gravity Forms. It facilitates the following: Adding a button for the field to the form editor Defining the field title to be used in the form editor Defining which settings should be present when editing the field Registering the field as compatible with conditional logic Outputting field scripts to the form editor and front-end Defining the field appearance on the front-end, in the form editor and on the entry detail page Validating the field during submission Saving the entry value Defining how the entry value is displayed when merge tags are processed, on the entries list and entry detail pages Defining how the entry value should be formatted when used in csv exports and by framework based add-ons

Source: includes/fields/class-gf-field.php:24

Details

  • Kind: class
  • Namespace: (global)
  • Extends: stdClass
  • Implements: ArrayAccess

Properties

PropertyTypeDescription
$is_paymentboolIndicates the field is used to capture payments.
$_supports_state_validationboolIndicates if this field supports state validation.
$duplicatableboolWhether there can be more than one of this field type per form.
$repeatableboolWhether the field can be used in a repeater.

Methods

MethodDescription
has_persistent_choices()Whether the choice field has entries that persist after changing the field type.
__get()The getter method of the field property.
set_context_property()Set a context property for this field.
set_input_validation_state()Set the validation state for a single input within this field.
get_default_properties()Get default properties for a field.
get_form_editor_field_title()Returns the field title.
get_form_editor_field_icon()Returns the field's form editor icon.
get_form_editor_field_type_icon()Returns the form editor icon for the field type.
get_form_editor_field_description()Returns the field's form editor description.
get_required_inputs_ids()Defines the IDs of required inputs.
get_form_editor_button()Returns the field button properties for the form editor. The array contains two elements:
get_form_editor_field_settings()Returns the class names of the settings which should be available on the field in the form editor.
is_conditional_logic_supported()Override to indicate if this field type can be used when configuring conditional logic rules.
get_form_editor_inline_script_on_page_render()Returns the scripts to be included for this field type in the form editor.
get_form_inline_script_on_page_render()Returns the scripts to be included with the form init scripts on the front-end.
get_field_input()Returns the field inner markup.
get_field_content()Returns the field markup; including field label, description, validation, and the form editor admin buttons.
get_field_label_tag()Returns the HTML tag for the field label.
get_field_sidebar_messages()Checks if any messages should be displayed in the sidebar for this field, and returns the HTML markup for them.
get_field_container()Returns the HTML markup for the field's containing element.
get_field_container_tag()Returns the HTML tag for the field container.
get_field_label_class()Get field label class.
get_field_css_class()Get field CSS class.
get_field_action_aria_label()Return an aria-label for a field action (delete, edit, duplicate).
is_value_submission_array()Whether this field expects an array during submission.
get_input_id_from_choice_key()Returns the input ID given the choice key for Multiple Choice and Image Choice fields.
get_choice_id_from_input_key()Returns the choice ID given the input key for Multiple Choice and Image Choice fields.
is_value_submission_empty()Used to determine the required validation result.
is_value_empty()Is the given value considered empty for this field.
validate()Override this method to perform custom validation logic.
set_required_error()Sets the failed_validation and validation_message properties for a required field error.
prepare_complex_validation_value()Override to modify the value before it's used to generate the complex validation message.
complex_validation_message()Create a validation message for a required field with multiple inputs.
get_input_property()Gets a property value from an input.
get_value_submission()Retrieve the field value on submission.
get_input_value_submission()Retrieve the input value on submission.
get_entry_inputs()Override and return null if a multi-input field value is to be stored under the field ID instead of the individual input IDs.
get_repeater_inputs()Returns inputs structure for use in repeater fields.
get_value_save_entry()Sanitize and format the value before it is saved to the Entry Object.
get_value_save_input()Sanitize and format the value before it is saved to the Entry Object.
get_value_merge_tag()Format the entry value for when the field/input merge tag is processed. Not called for the {all_fields} merge tag.
get_value_entry_list()Format the entry value for display on the entries list page.
get_value_entry_detail()Format the entry value for display on the entry detail page and for the {all_fields} merge tag.
get_value_export()Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().
filter_input_value()Apply the gform_get_input_value filter to an entry's value.
get_selected_choice_output()Prepares the selected choice from the entry for output.
get_selected_choice()Returns the choice array for the entry value.
get_conditional_logic_event()Maybe return the input attribute which will trigger evaluation of conditional logic rules which depend on this field.
get_tabindex()Maybe return the tabindex attribute.
get_field_placeholder_attribute()If the field placeholder property has a value return the input placeholder attribute.
get_placeholder_value()Process merge tags in the placeholder and return it.
get_input_placeholder_attribute()If the input placeholder property has a value return the input placeholder attribute.
get_input_placeholder_value()If configured retrieve the input placeholder value.
get_input_label()Return the custom label for an input.
get_input_label_class()Get the input label classes. When no custom label and placeholder for an input, we apply the
is_form_editor()Determine if the current location is the form editor.
is_entry_detail()Determine if the current location is the entry detail page.
is_entry_detail_edit()Determine if the current location is the edit entry page.
has_calculation()Is this a calculated product field or a number field with a calculation enabled and formula configured.
is_description_above()Determines if the field description should be positioned above or below the input.
is_sub_label_above()Determines if the field sub labels should be positioned above or below the input.
is_validation_above()Determines if the field validation message should be positioned above or below the input.
set_modifiers()Store the modifiers so they can be accessed in get_value_entry_detail() when preparing the content for the {all_fields} output.
get_modifiers()Retrieve the merge tag modifiers.
get_input_type()Retrieves the field input type.
add_button()Adds the field button to the specified group.
get_admin_buttons()Returns the field admin buttons for display in the form editor.
get_required_indicator()Get the text that indicates a field is required.
get_hidden_admin_markup()Get markup to show that the field is hidden in the form editor
get_field_label()Retrieve the field label.
get_first_input_id()Returns the input ID to be assigned to the field label for attribute.
maybe_add_aria_describedby()Set the aria-describedby attribute for an input if it is the first input in a fieldset
get_field_autocomplete_attribute()Get the autocomplete attribute for the field.
get_input_autocomplete_attribute()If the input autocomplete property has a value return the input autocomplete attribute.
parse_autocomplete_attributes()Parse a comma-separated list of autocomplete attributes.
get_description()Returns the markup for the field description.
get_aria_describedby()If a field has a description, the aria-describedby attribute for the input field is returned.
get_aria_attributes()Generates aria-describedby, aria-invalid and aria-required attributes for field inputs.
should_be_validated()Whether this field has been submitted,
is_state_validation_supported()Determines if this field will be processed by the state validation.
skip_state_validation_if_blank()Indicates if state validation should be skipped if the submitted value is blank.
is_state_valid()Determines the if the field has been tampered with before submission.
get_state_validation_message()Returns the validation message to be applied when the field has failed state validation.
get_choice_option_value()Gets a field choice value, including the price if enabled.
get_values_for_state_hash()Prepares the value that will be hashed on form display as part of the state.
get_value_for_state_validation()Returns the value to use when the state is validated.
get_inputs_describedby_attributes()Generates an array that contains aria-describedby attribute for each input.
get_inputs_required_attributes()Generates an array that contains aria-required attributes for each input.
get_inputs_invalid_attributes()Generates an array that contains aria-invalid attributes for each input.
get_value_default_if_empty()Returns the field default value if the field does not already have a value.
get_value_default()Retrieve the field default value.
get_css_grid_class()Get the appropriate CSS Grid class for the column span of the field.
register_form_init_scripts()Registers the script returned by get_form_inline_script_on_page_render() for display on the front-end.
strip_script_tag()Strip unsafe tags from the field value.
allow_html()Override this if the field should allow html tags to be saved with the entry value. Default is false.
sanitize_entry_value()Fields should override this method to implement the appropriate sanitization specific to the field type before the value is saved.
sanitize_settings()Forces settings into expected values while saving the form object.
sanitize_settings_choices()Sanitize the field choices property.
sanitize_settings_conditional_logic()Sanitize the field conditional logic object.
sanitize_autocomplete_attributes()Sanitize autocomplete attributes by checking them against whitelist.
maybe_wp_kses()Applies wp_kses() if the current user doesn't have the unfiltered_html capability
get_allowable_tags()Returns the allowed HTML tags for the field value.
post_convert_field()Actions to be performed after the field has been converted to an object.
get_size_choices()Returns the choices for the Field Size setting.
get_filter_settings()Returns the filter settings for the current field.
get_filter_operators()Returns the filter operators for the current field.
get_filter_values()Returns the filters values setting for the current field.
get_filter_sub_filters()Returns the sub-filters for the current field.
get_product_quantity_label()Get the product quantity label.
get_extra_entry_metadata()Returns an array of key value pairs to be saved to the entry meta after saving/updating the entry.
disable_ajax_reload()Decides if the field markup should not be reloaded after AJAX save.

Method Reference

has_persistent_choices()

public function has_persistent_choices()

Whether the choice field has entries that persist after changing the field type.

Returns

  • boolean

Since: 2.9

Source: includes/fields/class-gf-field.php:111

__get()

public function&__get( $key )

The getter method of the field property.

Parameters

NameTypeDefaultDescription
$keystringThe field property.

Returns

  • bool | mixed

Since:

  • unknown
  • 2.4.19 (Add whitelist for the size property.)

Source: includes/fields/class-gf-field.php:234

set_context_property()

public function set_context_property( $property_key, $value )

Set a context property for this field.

Parameters

NameTypeDefaultDescription
$property_keyarray | string
$valuemixed

Returns

  • void

Since:

  • 2.3
  • 2.5.10 (- Property key can be an array in order to set a nested value.)

Source: includes/fields/class-gf-field.php:283

set_input_validation_state()

public function set_input_validation_state( $input_id, $is_valid )

Set the validation state for a single input within this field.

Parameters

NameTypeDefaultDescription
$input_idstring
$is_validbool

Returns

  • void

Since: 2.5.10

Source: includes/fields/class-gf-field.php:318

get_default_properties()

public function get_default_properties()

Get default properties for a field.

Used to populate a field with default properties if any properties are required for a field to function correctly.

Returns

  • array

Since: 2.7.4

Source: includes/fields/class-gf-field.php:433

get_form_editor_field_title()

public function get_form_editor_field_title()

Returns the field title.

Returns

  • string

Source: includes/fields/class-gf-field.php:445

get_form_editor_field_icon()

public function get_form_editor_field_icon()

Returns the field's form editor icon.

This could be an icon url or a gform-icon class.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:458

get_form_editor_field_type_icon()

public function get_form_editor_field_type_icon()

Returns the form editor icon for the field type.

Sometimes the field type and the input type are not the same, but we want the field type icon.

Returns

  • string

Since: 2.9.0

Source: includes/fields/class-gf-field.php:471

get_form_editor_field_description()

public function get_form_editor_field_description()

Returns the field's form editor description.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:489

get_required_inputs_ids()

public function get_required_inputs_ids()

Defines the IDs of required inputs.

Returns

  • string[]

Since: 2.5

Source: includes/fields/class-gf-field.php:500

get_form_editor_button()

public function get_form_editor_button()

Returns the field button properties for the form editor. The array contains two elements:

'group' => 'standard_fields' // or 'advanced_fields', 'post_fields', 'pricing_fields' 'text' => 'Button text'

Built-in fields don't need to implement this because the buttons are added in sequence in GFFormDetail

Returns

  • array

Source: includes/fields/class-gf-field.php:513

get_form_editor_field_settings()

public function get_form_editor_field_settings()

Returns the class names of the settings which should be available on the field in the form editor.

Returns

  • array

Source: includes/fields/class-gf-field.php:527

is_conditional_logic_supported()

public function is_conditional_logic_supported()

Override to indicate if this field type can be used when configuring conditional logic rules.

Returns

  • bool

Source: includes/fields/class-gf-field.php:536

get_form_editor_inline_script_on_page_render()

public function get_form_editor_inline_script_on_page_render()

Returns the scripts to be included for this field type in the form editor.

Returns

  • string

Source: includes/fields/class-gf-field.php:545

get_form_inline_script_on_page_render()

public function get_form_inline_script_on_page_render( $form )

Returns the scripts to be included with the form init scripts on the front-end.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:556

get_field_input()

public function get_field_input( $form, $value='', $entry=null )

Returns the field inner markup.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.
$valuestring | array''The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
$entrynull | arraynullNull or the Entry Object currently being edited.

Returns

  • string

Source: includes/fields/class-gf-field.php:569

get_field_content()

public function get_field_content( $value, $force_frontend_label, $form )

Returns the field markup; including field label, description, validation, and the form editor admin buttons.

The {FIELD} placeholder will be replaced in GFFormDisplay::get_field_content with the markup returned by GF_Field::get_field_input().

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
$force_frontend_labelboolShould the frontend label be displayed in the admin even if an admin label is configured.
$formarrayThe Form Object currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:584

get_field_label_tag()

public function get_field_label_tag( $form )

Returns the HTML tag for the field label.

Parameters

NameTypeDefaultDescription
$formarrayThe current Form object.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:649

get_field_sidebar_messages()

public function get_field_sidebar_messages()

Checks if any messages should be displayed in the sidebar for this field, and returns the HTML markup for them.

Messages could be warning messages, that will be displayed in error style, or notification messages, that will be displayed in info style.

Returns

  • array[] | array | string — An array of arrays that lists all the messages and their types, an array that contains one message and type, or a warning message string that defaults to the warning type.

Since: 2.8.0

Source: includes/fields/class-gf-field.php:667

get_field_container()

public function get_field_container( $atts, $form )

Returns the HTML markup for the field's containing element.

Parameters

NameTypeDefaultDescription
$attsarrayContainer attributes.
$formarrayThe current Form object.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:681

get_field_container_tag()

public function get_field_container_tag( $form )

Returns the HTML tag for the field container.

Parameters

NameTypeDefaultDescription
$formarrayThe current Form object.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:747

get_field_label_class()

public function get_field_label_class()

Get field label class.

Returns

  • string

Since:

  • unknown
  • 2.5 (Added screen-reader-text if the label hasn't been set; added gfield_label_before_complex if the field has inputs.)
  • 2.7 (Added gform-field-label for the theme framework.)

Source: includes/fields/class-gf-field.php:762

get_field_css_class()

public function get_field_css_class()

Get field CSS class.

Returns

  • string

Since: 2.7

Source: includes/fields/class-gf-field.php:782

get_field_action_aria_label()

public function get_field_action_aria_label( $action='', $label='' )

Return an aria-label for a field action (delete, edit, duplicate).

Parameters

NameTypeDefaultDescription
$actionstr''The button action as descriptive text.
$labelstr''The field label.

Returns

  • str — The passed aria-label or an automatically generated label if it is blank.

Since: 2.5

Source: includes/fields/class-gf-field.php:796

is_value_submission_array()

public function is_value_submission_array()

Whether this field expects an array during submission.

Returns

  • bool

Since: 2.4

Source: includes/fields/class-gf-field.php:823

get_input_id_from_choice_key()

public function get_input_id_from_choice_key( $key )

Returns the input ID given the choice key for Multiple Choice and Image Choice fields.

Parameters

NameTypeDefaultDescription
$keystringThe choice key.

Returns

  • string

Since: 2.9

Source: includes/fields/class-gf-field.php:836

get_choice_id_from_input_key()

public function get_choice_id_from_input_key( $key )

Returns the choice ID given the input key for Multiple Choice and Image Choice fields.

Parameters

NameTypeDefaultDescription
$keystringThe choice key.

Returns

  • string

Since: 2.9

Source: includes/fields/class-gf-field.php:858

is_value_submission_empty()

public function is_value_submission_empty( $form_id )

Used to determine the required validation result.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form currently being processed.

Returns

  • bool

Source: includes/fields/class-gf-field.php:878

is_value_empty()

public function is_value_empty( $value )

Is the given value considered empty for this field.

Parameters

NameTypeDefaultDescription
$value

Returns

  • bool

Since: 2.4

Source: includes/fields/class-gf-field.php:945

validate()

public function validate( $value, $form )

Override this method to perform custom validation logic.

Return the result (bool) by setting $this->failed_validation. Return the validation message (string) by setting $this->validation_message.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value from get_value_submission().
$formarrayThe Form Object currently being processed.

Returns

  • void

Since: 1.9

Source: includes/fields/class-gf-field.php:1004

set_required_error()

public function set_required_error( $value, $require_complex_message=false )

Sets the failed_validation and validation_message properties for a required field error.

Parameters

NameTypeDefaultDescription
$valuemixedThe field value.
$require_complex_messageboolfalseIndicates if the field must have a complex validation message for the error to be set.

Returns

  • void

Since: 2.6.5

Source: includes/fields/class-gf-field.php:1018

prepare_complex_validation_value()

public function prepare_complex_validation_value( $value )

Override to modify the value before it's used to generate the complex validation message.

Parameters

NameTypeDefaultDescription
$valuearrayThe value to be prepared.

Returns

  • array

Since: 2.6.5

Source: includes/fields/class-gf-field.php:1042

complex_validation_message()

public function complex_validation_message( $value, $required_inputs )

Create a validation message for a required field with multiple inputs.

The validation message will specify which inputs need to be filled out.

Parameters

NameTypeDefaultDescription
$valuearrayThe value entered by the user.
$required_inputsarrayThe required inputs to validate.

Returns

  • string | false

Since:

  • 2.5
  • 2.6.5 (Updated to use prepare_complex_validation_value().)

Source: includes/fields/class-gf-field.php:1059

get_input_property()

public function get_input_property( $input_id, $property_name )

Gets a property value from an input.

Parameters

NameTypeDefaultDescription
$input_idintThe input ID to obtain the property from.
$property_namestringThe property name to search for.

Returns

  • null | string | array — The property value if found. Otherwise, null.

Since: Unknown

Source: includes/fields/class-gf-field.php:1099

get_value_submission()

public function get_value_submission( $field_values, $get_from_post_global_var=true )

Retrieve the field value on submission.

Parameters

NameTypeDefaultDescription
$field_valuesarrayThe dynamic population parameter names with their corresponding values to be populated.
$get_from_post_global_varbool | truetrueWhether to get the value from the $_POST array as opposed to $field_values.

Returns

  • array | string

Source: includes/fields/class-gf-field.php:1113

get_input_value_submission()

public function get_input_value_submission( $standard_name, $custom_name='', $field_values=[], $get_from_post_global_var=true )

Retrieve the input value on submission.

Parameters

NameTypeDefaultDescription
$standard_namestringThe input name used when accessing the $_POST.
$custom_namestring''The dynamic population parameter name.
$field_valuesarray[]The dynamic population parameter names with their corresponding values to be populated.
$get_from_post_global_varbool | truetrueWhether to get the value from the $_POST array as opposed to $field_values.

Returns

  • array | string | null

Since:

  • 1.9
  • 2.9.17 (Updated to return null if the field failed state validation.)

Source: includes/fields/class-gf-field.php:1142

get_entry_inputs()

public function get_entry_inputs()

Override and return null if a multi-input field value is to be stored under the field ID instead of the individual input IDs.

Returns

  • array | null

Source: includes/fields/class-gf-field.php:1164

get_repeater_inputs()

public function get_repeater_inputs()

Returns inputs structure for use in repeater fields.

This method allows fields to provide different input structure when used inside repeater fields vs standard entry processing. By default, it delegates to get_entry_inputs().

Returns

  • array | null — Array of inputs or null if field has no inputs.

Since: 3.0.0

Source: includes/fields/class-gf-field.php:1177

get_value_save_entry()

public function get_value_save_entry( $value, $form, $input_name, $lead_id, $lead )

Sanitize and format the value before it is saved to the Entry Object.

Parameters

NameTypeDefaultDescription
$valuestringThe value to be saved.
$formarrayThe Form Object currently being processed.
$input_namestringThe input name used when accessing the $_POST.
$lead_idintThe ID of the Entry currently being processed.
$leadarrayThe Entry Object currently being processed.

Returns

  • array | string — The safe value.

Source: includes/fields/class-gf-field.php:1192

get_value_save_input()

public function get_value_save_input( $value, $form, $input_name, $entry_id, $entry, $repeater_index='' )

Sanitize and format the value before it is saved to the Entry Object.

Parameters

NameTypeDefaultDescription
$valuestringThe value to be saved.
$formarrayThe Form Object currently being processed.
$input_namestringThe input name used when accessing the $_POST.
$entry_idintThe ID of the Entry currently being processed.
$entryarrayThe Entry Object currently being processed.
$repeater_indexstring''The repeater index if the field is inside a repeater.

Returns

  • array | string — The sanitized and formatted input value to be saved.

Since: 3.0.0

Source: includes/fields/class-gf-field.php:1211

get_value_merge_tag()

public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br )

Format the entry value for when the field/input merge tag is processed. Not called for the {all_fields} merge tag.

Return a value that is safe for the context specified by $format.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value. Depending on the location the merge tag is being used the following functions may have already been applied to the value: esc_html, nl2br, and urlencode.
$input_idstringThe field or input ID from the merge tag currently being processed.
$entryarrayThe Entry Object currently being processed.
$formarrayThe Form Object currently being processed.
$modifierstringThe merge tag modifier. e.g. value
$raw_valuestring | arrayThe raw field value from before any formatting was applied to $value.
$url_encodeboolIndicates if the urlencode function may have been applied to the $value.
$esc_htmlboolIndicates if the esc_html function may have been applied to the $value.
$formatstringThe format requested for the location the merge is being used. Possible values: html, text or url.
$nl2brboolIndicates if the nl2br function may have been applied to the $value.

Returns

  • string

Since: Unknown

Source: includes/fields/class-gf-field.php:1264

get_value_entry_list()

public function get_value_entry_list( $value, $entry, $field_id, $columns, $form )

Format the entry value for display on the entries list page.

Return a value that's safe to display on the page.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$entryarrayThe Entry Object currently being processed.
$field_idstringThe field or input ID currently being processed.
$columnsarrayThe properties for the columns being displayed on the entry list page.
$formarrayThe Form Object currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:1318

get_value_entry_detail()

public function get_value_entry_detail( $value, $currency='', $use_text=false, $format='html', $media='screen' )

Format the entry value for display on the entry detail page and for the {all_fields} merge tag.

Return a value that's safe to display for the context of the given $format.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$currencystring''The entry currency code.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstring'html'The format requested for the location the merge is being used. Possible values: html, text or url.
$mediastring'screen'The location where the value will be displayed. Possible values: screen or email.

Returns

  • string | false

Since:

  • 1.9
  • 2.9.14 (Updated to display an inline error message on the entry detail page for array-based values.)

Source: includes/fields/class-gf-field.php:1348

get_value_export()

public function get_value_export( $entry, $input_id='', $use_text=false, $is_csv=false )

Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().

For CSV export return a string or array.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry currently being processed.
$input_idstring''The field or input ID.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$is_csvbool | falsefalseIs the value going to be used in the .csv entries export?

Returns

  • string | array

Source: includes/fields/class-gf-field.php:1404

filter_input_value()

public function filter_input_value( $value, $entry, $input_id='' )

Apply the gform_get_input_value filter to an entry's value.

Parameters

NameTypeDefaultDescription
$valuemixedThe field or input value to be filtered.
$entryarrayThe entry currently being processed.
$input_idstring''The ID of the input being processed from a multi-input field type or an empty string.

Returns

  • mixed

Since: 2.4.24

Source: includes/fields/class-gf-field.php:1423

get_selected_choice_output()

public function get_selected_choice_output( $value, $currency='', $use_text=false )

Prepares the selected choice from the entry for output.

Parameters

NameTypeDefaultDescription
$valuestringThe choice value from the entry.
$currencystring''The entry currency code.
$use_textboolfalseIndicates if the choice text should be returned instead of the choice value.

Returns

  • string

Since: 2.5.11

Source: includes/fields/class-gf-field.php:1459

get_selected_choice()

public function get_selected_choice( $value )

Returns the choice array for the entry value.

Parameters

NameTypeDefaultDescription
$valuestringThe choice value from the entry.

Returns

  • array

Since: 2.5.11

Source: includes/fields/class-gf-field.php:1497

get_conditional_logic_event()

public function get_conditional_logic_event( $event )

Maybe return the input attribute which will trigger evaluation of conditional logic rules which depend on this field.

Parameters

NameTypeDefaultDescription
$eventstringThe event attribute which should be returned. Possible values: keyup, click, or change.

Returns

  • string

Since: 2.4

Deprecated: 2.4 (Conditional Logic is now triggered based on .gfield class name. No need to hardcode calls to gf_apply_rules() to every field.)

Source: includes/fields/class-gf-field.php:1525

get_tabindex()

public function get_tabindex()

Maybe return the tabindex attribute.

Returns

  • string

Source: includes/fields/class-gf-field.php:1553

get_field_placeholder_attribute()

public function get_field_placeholder_attribute()

If the field placeholder property has a value return the input placeholder attribute.

Returns

  • string

Source: includes/fields/class-gf-field.php:1562

get_placeholder_value()

public function get_placeholder_value( $placeholder )

Process merge tags in the placeholder and return it.

Parameters

NameTypeDefaultDescription
$placeholderstringThe placeholder value.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:1578

get_input_placeholder_attribute()

public function get_input_placeholder_attribute( $input )

If the input placeholder property has a value return the input placeholder attribute.

Parameters

NameTypeDefaultDescription
$inputarrayThe input currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:1640

get_input_placeholder_value()

public function get_input_placeholder_value( $input )

If configured retrieve the input placeholder value.

Parameters

NameTypeDefaultDescription
$inputarrayThe input currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:1654

get_input_label()

public function get_input_label( $input )

Return the custom label for an input.

Parameters

NameTypeDefaultDescription
$inputarrayThe input object.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:1670

get_input_label_class()

public function get_input_label_class( $input, $label_class )

Get the input label classes. When no custom label and placeholder for an input, we apply the

screen-reader-text class to the label.

Parameters

NameTypeDefaultDescription
$inputarrayThe input object.
$label_classarrayThe label classes.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:1689

is_form_editor()

public function is_form_editor()

Determine if the current location is the form editor.

Returns

  • bool

Source: includes/fields/class-gf-field.php:1709

is_entry_detail()

public function is_entry_detail()

Determine if the current location is the entry detail page.

Returns

  • bool

Source: includes/fields/class-gf-field.php:1718

is_entry_detail_edit()

public function is_entry_detail_edit()

Determine if the current location is the edit entry page.

Returns

  • bool

Source: includes/fields/class-gf-field.php:1727

has_calculation()

public function has_calculation()

Is this a calculated product field or a number field with a calculation enabled and formula configured.

Returns

  • bool

Source: includes/fields/class-gf-field.php:1736

is_description_above()

public function is_description_above( $form )

Determines if the field description should be positioned above or below the input.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • bool

Source: includes/fields/class-gf-field.php:1762

is_sub_label_above()

public function is_sub_label_above( $field_sub_label_placement, $form_sub_label_placement )

Determines if the field sub labels should be positioned above or below the input.

Parameters

NameTypeDefaultDescription
$field_sub_label_placementstringThe sub label placement setting for the field.
$form_sub_label_placementstringThe sub label placement setting for the form.

Returns

  • bool

Since: 3.0.0

Source: includes/fields/class-gf-field.php:1802

is_validation_above()

public function is_validation_above( $form )

Determines if the field validation message should be positioned above or below the input.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • bool

Since: 2.8.8

Source: includes/fields/class-gf-field.php:1820

set_modifiers()

public function set_modifiers( $modifiers )

Store the modifiers so they can be accessed in get_value_entry_detail() when preparing the content for the {all_fields} output.

Parameters

NameTypeDefaultDescription
$modifiersarrayAn array of modifiers to be stored.

Source: includes/fields/class-gf-field.php:1846

get_modifiers()

public function get_modifiers()

Retrieve the merge tag modifiers.

Returns

  • array

Source: includes/fields/class-gf-field.php:1856

get_input_type()

public function get_input_type()

Retrieves the field input type.

Returns

  • string

Source: includes/fields/class-gf-field.php:1866

add_button()

public function add_button( $field_groups )

Adds the field button to the specified group.

Parameters

NameTypeDefaultDescription
$field_groupsarray

Returns

  • array

Source: includes/fields/class-gf-field.php:1878

get_admin_buttons()

public function get_admin_buttons()

Returns the field admin buttons for display in the form editor.

Returns

  • string

Source: includes/fields/class-gf-field.php:1921

get_required_indicator()

public function get_required_indicator()

Get the text that indicates a field is required.

Returns

  • string — HTML for required indicator.

Since: 2.5

Source: includes/fields/class-gf-field.php:2057

get_hidden_admin_markup()

public function get_hidden_admin_markup()

Get markup to show that the field is hidden in the form editor

Returns

  • string — HTML for required indicator.

Since: 2.5

Source: includes/fields/class-gf-field.php:2068

get_field_label()

public function get_field_label( $force_frontend_label=true, $value='' )

Retrieve the field label.

Parameters

NameTypeDefaultDescription
$force_frontend_labelbooltrueShould the frontend label be displayed in the admin even if an admin label is configured.
$valuestring''The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.

Returns

  • string

Since:

  • unknown
  • 2.5 (Move conditions about the singleproduct and calculation fields to their own class.)
  • 3.0 (Made the params optional.)

Source: includes/fields/class-gf-field.php:2086

get_first_input_id()

public function get_first_input_id( $form )

Returns the input ID to be assigned to the field label for attribute.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:2107

maybe_add_aria_describedby()

public function maybe_add_aria_describedby( $input, $field_id, $form_id )

Set the aria-describedby attribute for an input if it is the first input in a fieldset

Since 2.5

Parameters

NameTypeDefaultDescription
$inputarrayThe current input.
$field_idstringThe ID of the field we're working with.
$form_idintThe ID of the form object.

Returns

  • string — The aria-describedby text or a blank string.

Source: includes/fields/class-gf-field.php:2145

get_field_autocomplete_attribute()

public function get_field_autocomplete_attribute()

Get the autocomplete attribute for the field.

Returns

  • string | void — $autocomplete The autocomplete attribute for the field.

Since: 2.5

Source: includes/fields/class-gf-field.php:2165

get_input_autocomplete_attribute()

public function get_input_autocomplete_attribute( $input )

If the input autocomplete property has a value return the input autocomplete attribute.

Parameters

NameTypeDefaultDescription
$inputarrayThe input currently being processed.

Returns

  • string | void — $autocomplete The autocomplete attribute for the input.

Since: 2.5

Source: includes/fields/class-gf-field.php:2184

parse_autocomplete_attributes()

public function parse_autocomplete_attributes( $attributes )

Parse a comma-separated list of autocomplete attributes.

In case the user has put commas in between multiple autocomplete attributes, remove the commas.

Parameters

NameTypeDefaultDescription
$attributesstring

Returns

  • string — List of attributes separated by a space.

Since: 2.5

Source: includes/fields/class-gf-field.php:2208

get_description()

public function get_description( $description, $css_class )

Returns the markup for the field description.

Parameters

NameTypeDefaultDescription
$descriptionstringThe field description.
$css_classstringThe css class to be assigned to the description container.

Returns

  • string

Source: includes/fields/class-gf-field.php:2222

get_aria_describedby()

public function get_aria_describedby( $extra_ids=[] )

If a field has a description, the aria-describedby attribute for the input field is returned.

Parameters

NameTypeDefaultDescription
$extra_idsarray | string[]Any extra ids that should be added to the describedby attribute.

Returns

  • string

Since:

  • unknown
  • 2.5 (Add new param $extra_ids.)

Source: includes/fields/class-gf-field.php:2246

get_aria_attributes()

public function get_aria_attributes( $values, $input_id='' )

Generates aria-describedby, aria-invalid and aria-required attributes for field inputs.

Parameters

NameTypeDefaultDescription
$valuesarray | stringThe inputs values.
$input_idstring''The specific input ID we'd like to get the values from.

Returns

  • string | array — Return the attributes as a string if an input ID is given; otherwise return an array.

Since: 2.5

Source: includes/fields/class-gf-field.php:2277

should_be_validated()

public function should_be_validated()

Whether this field has been submitted,

is on the current page of a multi-page form, or is required and should be validated.

Returns

  • bool

Since: 2.5.7

Source: includes/fields/class-gf-field.php:2306

is_state_validation_supported()

public function is_state_validation_supported()

Determines if this field will be processed by the state validation.

Returns

  • bool

Since: 2.5.11

Source: includes/fields/class-gf-field.php:2329

skip_state_validation_if_blank()

public function skip_state_validation_if_blank( $key )

Indicates if state validation should be skipped if the submitted value is blank.

Parameters

NameTypeDefaultDescription
$keystring | intThe field or input ID.

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field.php:2342

is_state_valid()

public function is_state_valid( $value )

Determines the if the field has been tampered with before submission.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe submitted value.

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field.php:2355

get_state_validation_message()

public function get_state_validation_message()

Returns the validation message to be applied when the field has failed state validation.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field.php:2375

get_choice_option_value()

public function get_choice_option_value( $choice )

Gets a field choice value, including the price if enabled.

Parameters

NameTypeDefaultDescription
$choicearrayThe choice properties.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field.php:2392

get_values_for_state_hash()

public function get_values_for_state_hash( $value )

Prepares the value that will be hashed on form display as part of the state.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe default value.

Returns

  • null | array

Since: 3.0

Source: includes/fields/class-gf-field.php:2436

get_value_for_state_validation()

public function get_value_for_state_validation( $value )

Returns the value to use when the state is validated.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe submitted value.

Returns

  • array

Since: 3.0

Source: includes/fields/class-gf-field.php:2449

get_inputs_describedby_attributes()

public function get_inputs_describedby_attributes( $required_inputs_ids, $values )

Generates an array that contains aria-describedby attribute for each input.

Depending on each input's validation state, aria-describedby takes the value of the validation message container ID, the description only or nothing.

Parameters

NameTypeDefaultDescription
$required_inputs_idsarrayIDs of required field inputs.
$valuesarray | stringInputs values.

Returns

  • array

Since: 2.5

Source: includes/fields/class-gf-field.php:2470

get_inputs_required_attributes()

public function get_inputs_required_attributes( $required_inputs_ids )

Generates an array that contains aria-required attributes for each input.

Parameters

NameTypeDefaultDescription
$required_inputs_idsarrayIDs of required field inputs.

Returns

  • array

Since: 2.5

Source: includes/fields/class-gf-field.php:2506

get_inputs_invalid_attributes()

public function get_inputs_invalid_attributes( $required_inputs_ids, $values )

Generates an array that contains aria-invalid attributes for each input.

Parameters

NameTypeDefaultDescription
$required_inputs_idsarrayIDs of required field inputs.
$valuesarray | stringInputs values.

Returns

  • array

Since: 2.5

Source: includes/fields/class-gf-field.php:2536

get_value_default_if_empty()

public function get_value_default_if_empty( $value )

Returns the field default value if the field does not already have a value.

Parameters

NameTypeDefaultDescription
$valuearray | stringThe field value.

Returns

  • array | string

Source: includes/fields/class-gf-field.php:2574

get_value_default()

public function get_value_default()

Retrieve the field default value.

Returns

  • array | string

Source: includes/fields/class-gf-field.php:2597

get_css_grid_class()

public function get_css_grid_class( $form='' )

Get the appropriate CSS Grid class for the column span of the field.

Parameters

NameTypeDefaultDescription
$formarray''

Returns

  • string

Since:

  • 2.5
  • 2.6 (Added $form parameter)

Source: includes/fields/class-gf-field.php:2656

register_form_init_scripts()

public function register_form_init_scripts( $form )

Registers the script returned by get_form_inline_script_on_page_render() for display on the front-end.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Source: includes/fields/class-gf-field.php:2701

strip_script_tag()

public function strip_script_tag( $string )

Strip unsafe tags from the field value.

Parameters

NameTypeDefaultDescription
$stringstringThe field value to be processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:2714

allow_html()

public function allow_html()

Override this if the field should allow html tags to be saved with the entry value. Default is false.

Returns

  • bool

Source: includes/fields/class-gf-field.php:2727

sanitize_entry_value()

public function sanitize_entry_value( $value, $form_id )

Fields should override this method to implement the appropriate sanitization specific to the field type before the value is saved.

This base method will only strip HTML tags if the field or the gform_allowable_tags filter allows HTML.

Parameters

NameTypeDefaultDescription
$valuestringThe field value to be processed.
$form_idintThe ID of the form currently being processed.

Returns

  • string

Source: includes/fields/class-gf-field.php:2742

sanitize_settings()

public function sanitize_settings()

Forces settings into expected values while saving the form object.

No escaping should be done at this stage to prevent double escaping on output.

Currently called only for forms created after version 1.9.6.10.

Source: includes/fields/class-gf-field.php:2780

sanitize_settings_choices()

public function sanitize_settings_choices( $choices=null )

Sanitize the field choices property.

Parameters

NameTypeDefaultDescription
$choicesarray | nullnullThe field choices property.

Returns

  • array | null

Source: includes/fields/class-gf-field.php:2895

sanitize_settings_conditional_logic()

public function sanitize_settings_conditional_logic( $logic=null )

Sanitize the field conditional logic object.

Parameters

NameTypeDefaultDescription
$logicarray | nullnullThe field conditional logic object.

Returns

  • array | null

Source: includes/fields/class-gf-field.php:2938

sanitize_autocomplete_attributes()

public function sanitize_autocomplete_attributes( $autocomplete )

Sanitize autocomplete attributes by checking them against whitelist.

Parameters

NameTypeDefaultDescription
$autocompletestringThe user-entered autocomplete attributes in a comma-separated list.

Returns

  • string — Comma-separated list of acceptable attributes.

See Also

Since: 2.5

Source: includes/fields/class-gf-field.php:2959

maybe_wp_kses()

public function maybe_wp_kses( $html, $allowed_html='post', $allowed_protocols=[] )

Applies wp_kses() if the current user doesn't have the unfiltered_html capability

Parameters

NameTypeDefaultDescription
$html
$allowed_htmlstring'post'
$allowed_protocolsarray[]

Returns

  • string

Source: includes/fields/class-gf-field.php:3028

get_allowable_tags()

public function get_allowable_tags( $form_id=null )

Returns the allowed HTML tags for the field value.

FALSE disallows HTML tags. TRUE allows all HTML tags allowed by wp_kses_post(). A string of HTML tags allowed. e.g. '<p><a><strong><em>'

Parameters

NameTypeDefaultDescription
$form_idnull | intnullIf not specified the form_id field property is used.

Returns

  • bool | string — TRUE, FALSE or a string of tags.

Source: includes/fields/class-gf-field.php:3043

post_convert_field()

public function post_convert_field()

Actions to be performed after the field has been converted to an object.

Since:

  • 2.1.3 (Clear any field validation errors that have been saved to the form in the database.)
  • 2.5.11 (Set validateState property for back-compat.)
  • 2.7.4 (Set default properties.)

Source: includes/fields/class-gf-field.php:3076

get_size_choices()

public function get_size_choices( $values_only=false )

Returns the choices for the Field Size setting.

Parameters

NameTypeDefaultDescription
$values_onlyboolfalseIndicates if only the choice values should be returned.

Returns

  • array

Since: 2.4.19

Source: includes/fields/class-gf-field.php:3107

get_filter_settings()

public function get_filter_settings()

Returns the filter settings for the current field.

If overriding to add custom settings call the parent method first to get the default settings.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field.php:3137

get_filter_operators()

public function get_filter_operators()

Returns the filter operators for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field.php:3167

get_filter_values()

public function get_filter_values()

Returns the filters values setting for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field.php:3178

get_filter_sub_filters()

public function get_filter_sub_filters()

Returns the sub-filters for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field.php:3208

get_product_quantity_label()

public function get_product_quantity_label( $form_id )

Get the product quantity label.

Parameters

NameTypeDefaultDescription
$form_idintThe form ID.

Returns

  • string

Since: 2.5

Source: includes/fields/class-gf-field.php:3221

get_extra_entry_metadata()

public function get_extra_entry_metadata( $form, $entry )

Returns an array of key value pairs to be saved to the entry meta after saving/updating the entry.

Parameters

NameTypeDefaultDescription
$formarrayThe form object being saved.
$entryarrayThe entry object being saved

Returns

  • array — The array that contains the key/value pairs to be stored as extra meta data.

Since: 2.5.16

Source: includes/fields/class-gf-field.php:3247

disable_ajax_reload()

public function disable_ajax_reload()

Decides if the field markup should not be reloaded after AJAX save.

Returns

  • boolean

Since: 2.6

Source: includes/fields/class-gf-field.php:3258