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
| Property | Type | Description |
|---|---|---|
$is_payment | bool | Indicates the field is used to capture payments. |
$_supports_state_validation | bool | Indicates if this field supports state validation. |
$duplicatable | bool | Whether there can be more than one of this field type per form. |
$noURLs | bool | Whether this field allows links/URLs in the value. |
$repeatable | bool | Whether the field can be used in a repeater. |
Methods
| Method | Description |
|---|---|
has_persistent_choices() | Whether the choice field has entries that persist after changing the field type. |
__set() | Magic __set handler called when attempting to set an inaccessible or non-existing property. |
__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_label_id() | Get field label ID. |
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. |
value_contains_url() | Uses regex to determine if the value contains a link or URL. |
prepare_value_for_url_detection() | Returns the string value to be used for URL detection. |
should_detect_urls() | Determines if Links/URLs should be detected. |
should_show_validation_error() | Whether this field should show a validation error in the markup. |
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. |
prepare_post_category_value_save_input() | Sanitize and formats the post category field value before it is saved to the database. |
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_entry_allowed_html() | Returns the allowed HTML for entry values displayed as HTML. |
get_value_all_fields_merge_tag() | Returns the field value formatted for the {all_fields} merge tag. |
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_aria_labelledby() | Returns the aria-labelledby attribute linking an input label and the fieldset legend. |
maybe_add_aria_labelledby() | Set the aria-labelledby attribute for an input if it is the first input in a fieldset. |
get_first_input_aria_labels() | Returns aria-describedby and aria-labelledby for the first input in a fieldset. |
is_first_input() | Determines whether the given input is the first visible input for this field. |
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. |
get_field_choice_alignment() | Get the choice alignment for the given field. |
get_default_choice_alignment() | Get the default choice alignment for the multi_choice field. |
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. |
post_entry_value_sanitization() | Post entry value sanitization. Logs a message if the value was sanitized during the entry save process. |
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:121
__set()
public function __set( $key, $value )
Magic __set handler called when attempting to set an inaccessible or non-existing property.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The property key. | |
$value | mixed | The property value |
Returns
void
Since:
1.93.0.0(Updated to set a context property for adminonly_hidden instead of inputType.)
Source: includes/fields/class-gf-field.php:231
__get()
public function&__get( $key )
The getter method of the field property.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The field property. |
Returns
bool|mixed
Since:
unknown2.4.19(Add whitelist for the size property.)
Source: includes/fields/class-gf-field.php:259
set_context_property()
public function set_context_property( $property_key, $value )
Set a context property for this field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$property_key | array | string | ||
$value | mixed |
Returns
void
Since:
2.32.5.10(- Property key can be an array in order to set a nested value.)
Source: includes/fields/class-gf-field.php:308
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
| Name | Type | Default | Description |
|---|---|---|---|
$input_id | string | ||
$is_valid | bool |
Returns
void
Since: 2.5.10
Source: includes/fields/class-gf-field.php:343
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:458
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:470
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:483
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:496
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:514
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:525
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:538
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:552
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:561
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:570
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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The Form Object currently being processed. |
Returns
string
Source: includes/fields/class-gf-field.php:581
get_field_input()
public function get_field_input( $form, $value='', $entry=null )
Returns the field inner markup.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The Form Object currently being processed. | |
$value | string | array | '' | The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. |
$entry | null | array | null | Null or the Entry Object currently being edited. |
Returns
string
Source: includes/fields/class-gf-field.php:594
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. | |
$force_frontend_label | bool | Should the frontend label be displayed in the admin even if an admin label is configured. | |
$form | array | The Form Object currently being processed. |
Returns
string
Source: includes/fields/class-gf-field.php:609
get_field_label_tag()
public function get_field_label_tag( $form )
Returns the HTML tag for the field label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field.php:675
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:693
get_field_container()
public function get_field_container( $atts, $form )
Returns the HTML markup for the field's containing element.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$atts | array | Container attributes. | |
$form | array | The current Form object. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field.php:707
get_field_container_tag()
public function get_field_container_tag( $form )
Returns the HTML tag for the field container.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field.php:786
get_field_label_class()
public function get_field_label_class()
Get field label class.
Returns
string
Since:
unknown2.5(Addedscreen-reader-textif the label hasn't been set; addedgfield_label_before_complexif the field has inputs.)2.7(Addedgform-field-labelfor the theme framework.)
Source: includes/fields/class-gf-field.php:801
get_field_label_id()
public function get_field_label_id()
Get field label ID.
Returns
string
Since: 3.2.0
Source: includes/fields/class-gf-field.php:821
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:832
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
| Name | Type | Default | Description |
|---|---|---|---|
$action | str | '' | The button action as descriptive text. |
$label | str | '' | 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:846
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:873
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
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The choice key. |
Returns
string
Since: 2.9
Source: includes/fields/class-gf-field.php:886
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
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The choice key. |
Returns
string
Since: 2.9
Source: includes/fields/class-gf-field.php:908
is_value_submission_empty()
public function is_value_submission_empty( $form_id )
Used to determine the required validation result.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form currently being processed. |
Returns
bool
Since:
1.93.0(Added value sanitization to ensure that values that are empty after sanitization are not considered valid.)
Source: includes/fields/class-gf-field.php:931
is_value_empty()
public function is_value_empty( $value )
Is the given value considered empty for this field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value |
Returns
bool
Since:
2.43.0(Added value sanitization to ensure that values that are empty after sanitization are not considered valid.)
Source: includes/fields/class-gf-field.php:1010
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value from get_value_submission(). | |
$form | array | The Form Object currently being processed. |
Returns
void
Since: 1.9
Source: includes/fields/class-gf-field.php:1087
value_contains_url()
public function value_contains_url( $value )
Uses regex to determine if the value contains a link or URL.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value to be checked. |
Returns
bool
Since: 3.1.0
Source: includes/fields/class-gf-field.php:1100
prepare_value_for_url_detection()
public function prepare_value_for_url_detection( $value )
Returns the string value to be used for URL detection.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The value to be prepared for validation. |
Returns
string
Since: 3.1.0
Source: includes/fields/class-gf-field.php:1129
should_detect_urls()
public function should_detect_urls()
Determines if Links/URLs should be detected.
Returns
bool
Since: 3.1.0
Source: includes/fields/class-gf-field.php:1144
should_show_validation_error()
public function should_show_validation_error()
Whether this field should show a validation error in the markup.
Repeater fields keep failed_validation for their subfields, and do not show the error class or message themselves.
Returns
bool
Since: 3.2.0
Source: includes/fields/class-gf-field.php:1157
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | The field value. | |
$require_complex_message | bool | false | Indicates 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:1171
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | array | The value to be prepared. |
Returns
array
Since: 2.6.5
Source: includes/fields/class-gf-field.php:1195
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | array | The value entered by the user. | |
$required_inputs | array | The required inputs to validate. |
Returns
string|false
Since:
2.52.6.5(Updated to use prepare_complex_validation_value().)
Source: includes/fields/class-gf-field.php:1212
get_input_property()
public function get_input_property( $input_id, $property_name )
Gets a property value from an input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$input_id | int | The input ID to obtain the property from. | |
$property_name | string | The 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:1252
get_value_submission()
public function get_value_submission( $field_values, $get_from_post_global_var=true )
Retrieve the field value on submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field_values | array | The dynamic population parameter names with their corresponding values to be populated. | |
$get_from_post_global_var | bool | true | true | Whether to get the value from the $_POST array as opposed to $field_values. |
Returns
array|string
Source: includes/fields/class-gf-field.php:1266
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
| Name | Type | Default | Description |
|---|---|---|---|
$standard_name | string | The input name used when accessing the $_POST. | |
$custom_name | string | '' | The dynamic population parameter name. |
$field_values | array | [] | The dynamic population parameter names with their corresponding values to be populated. |
$get_from_post_global_var | bool | true | true | Whether to get the value from the $_POST array as opposed to $field_values. |
Returns
array|string|null
Since:
1.92.9.17(Updated to return null if the field failed state validation.)
Source: includes/fields/class-gf-field.php:1295
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:1317
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:1330
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The value to be saved. | |
$form | array | The Form Object currently being processed. | |
$input_name | string | The input name used when accessing the $_POST. | |
$lead_id | int | The ID of the Entry currently being processed. | |
$lead | array | The Entry Object currently being processed. |
Returns
array|string— The safe value.
Deprecated: 3.0
Source: includes/fields/class-gf-field.php:1348
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The value to be saved. | |
$form | array | The Form Object currently being processed. | |
$input_name | string | The input name used when accessing the $_POST. | |
$entry_id | int | The ID of the Entry currently being processed. | |
$entry | array | The Entry Object currently being processed. | |
$repeater_index | string | '' | 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:1367
prepare_post_category_value_save_input()
public function prepare_post_category_value_save_input( $value )
Sanitize and formats the post category field value before it is saved to the database.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | array | string | The selected post categories. |
Returns
array|string
Since: 3.0.3
Source: includes/fields/class-gf-field.php:1408
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The 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_id | string | The field or input ID from the merge tag currently being processed. | |
$entry | array | The Entry Object currently being processed. | |
$form | array | The Form Object currently being processed. | |
$modifier | string | The merge tag modifier. e.g. value | |
$raw_value | string | array | The raw field value from before any formatting was applied to $value. | |
$url_encode | bool | Indicates if the urlencode function may have been applied to the $value. | |
$esc_html | bool | Indicates if the esc_html function may have been applied to the $value. | |
$format | string | The format requested for the location the merge is being used. Possible values: html, text or url. | |
$nl2br | bool | Indicates if the nl2br function may have been applied to the $value. |
Returns
string
Since: Unknown
Source: includes/fields/class-gf-field.php:1464
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | The Entry Object currently being processed. | |
$field_id | string | The field or input ID currently being processed. | |
$columns | array | The properties for the columns being displayed on the entry list page. | |
$form | array | The Form Object currently being processed. |
Returns
string
Source: includes/fields/class-gf-field.php:1519
get_entry_allowed_html()
public function get_entry_allowed_html( $allowable_tags=true )
Returns the allowed HTML for entry values displayed as HTML.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$allowable_tags | bool | string | array | true | The tags permitted by the field and form policy. |
Returns
array
Since: 3.1.2
Source: includes/fields/class-gf-field.php:1541
get_value_all_fields_merge_tag()
public function get_value_all_fields_merge_tag( $value, $entry, $use_text, $format )
Returns the field value formatted for the {all_fields} merge tag.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | The entry. | |
$use_text | bool | false | When processing choice based fields should the choice text be returned instead of the value. | |
$format | string | The format requested for the location the merge is being used. Possible values: html, text or url. |
Returns
string|false
Since: 2.9.31
Source: includes/fields/class-gf-field.php:1597
get_value_entry_detail()
public function get_value_entry_detail( $value, $entry=[], $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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | [] | The entry. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$format | string | 'html' | The format requested for the location the merge is being used. Possible values: html, text or url. |
$media | string | 'screen' | The location where the value will be displayed. Possible values: screen or email. |
Returns
string|false
Since:
1.92.9.14(Updated to display an inline error message on the entry detail page for array-based values.)2.9.29(Changed the second parameter $currency (string) to $entry (array).)
Source: includes/fields/class-gf-field.php:1619
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
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry currently being processed. | |
$input_id | string | '' | The field or input ID. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$is_csv | bool | false | false | Is the value going to be used in the .csv entries export? |
Returns
string|array
Source: includes/fields/class-gf-field.php:1674
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
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | The field or input value to be filtered. | |
$entry | array | The entry currently being processed. | |
$input_id | string | '' | 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:1870