GFFormDisplay
Source: form_display.php:10
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
process_form() | Starting point for the form submission process. Handles the following tasks: Form validation, save for later logic, entry creation, notification and confirmation. |
maybe_add_review_page() | Get form object and insert review page, if necessary. |
get_state() | Gets the value for the state input. |
get_state_handler() | Returns the state handler. |
is_last_page() | Determine if the last page for the current form object is being submitted or rendered (depending on the provided $mode). |
get_form_theme_slug() | Get the slug for the form's theme |
get_themes_to_enqueue() | Determines which themes to enqueue based on the form context and current page. |
post_render_script() | Fire the post render events for a form instance when the form is visible on the page. |
get_form() | Get a form for display. |
get_page() | Get the markup for a specific page in a multipage form. |
get_fields() | Get the markup for a colletion of fields in a form. If $page_number is specified, only the markup for the fields on that page will be returned. Otherwise, the markup for all fields in the form will be returned. |
get_fields_by_page() | Gets the fields for a specific page in a form. |
get_submit_button_class() | Get the CSS class for the submit button. |
get_max_field_id() | Get the maximum field ID for the current form. |
is_empty() | Used to determine the required validation result. |
handle_submission() | Triggers saving or updating of the entry, spam eval, post creation, sending of notifications, and then returns the confirmation to be used for the current submission. |
clean_up_files() | Deletes tmp files for the given form. |
handle_confirmation() | Prepares the confirmation message or redirect to be used by the current submission. |
get_confirmation_url() | Returns the redirect URL for the current submission. |
get_confirmation_message() | Gets the confirmation message to be displayed. |
get_submission_context() | Returns the context for the current submission. |
validate() | Determines if the current form submission is valid. |
validate_field() | Validates the submitted value of the given field. |
validate_character_encoding() | Checks for valid character encoding in the submitted value of the given field. |
is_field_validation_supported() | Determines if the supplied field is suitable for validation. |
is_form_empty() | Determines if the current form submission is empty. |
failed_state_validation() | Determines if the field has been tampered with. |
enqueue_scripts() | Enqueues scripts/styles for forms embedded via blocks and shortcodes. |
parse_forms() | Parses the supplied post content for forms embedded via blocks and shortcodes. |
parse_forms_from_blocks() | Finds forms embedded in the supplied blocks. |
parse_forms_from_reusable_block() | Finds forms embedded in the supplied reusable block. |
parse_forms_from_shortcode() | Finds forms embedded in the supplied post content. |
is_applicable_form() | Determines if the supplied form ID should be added to the found forms array. |
get_embedded_forms() | Returns forms embedded in the supplied post content. |
get_form_enqueue_assets() | Get the various enqueueable assets for a given form. |
enqueue_form_scripts() | Enqueue the required scripts for this form. |
add_script_defer() | Add defer attribute to Gravity Forms scripts and any script dependent on a Gravity Forms script. |
print_form_scripts() | Print the required scripts for this form, since we're hooking in after enqueues have processed. |
has_image_choices() | Check if a form has any Image Choice fields. |
has_page_conditional_logic() | Determines if the form has page conditional logic. |
register_form_init_scripts() | Enqueue and retrieve all inline scripts that should be executed when the form is rendered. |
get_counter_init_script() | Deprecated. No replacement. Text counter settings are rendered as properties to the element in the markup. |
get_number_formats_script() | Generates a map of fields IDs and their corresponding number formats used by the GFCalc JS object for correctly |
has_field_input_mask() | Determines if the current field has an input mask. |
get_field() | Gets the markup for a given field. |
get_field_content() | |
validate_entry_limit() | Validates the form's entry limit settings. Returns the entry limit message if entry limit exceeded. |
update_confirmation() | Populates the form confirmation property with the confirmation to be used for the current submission. |
insert_review_page() | Insert review page into form. |
get_anchor() | Get the anchor config for the current form. |
is_submit_form_id_valid() | Validates the posted input values from the form footer are for the same form, that it exists, is active, and not trashed. |
get_submission_method() | Returns the safe value of/for the gform_submission_method input. |
is_iframe_submission_method() | Determines if the iframe-based Ajax submission method is in use. |
parse_ajax_input() | Parses and sanitizes the value of the gform_ajax input. |
prepare_ajax_input_value() | Prepares the value for the gform_ajax input. |
get_ajax_postback_html() | Returns the HTML for the ajax postback. |
get_form_not_found_html() | Returns the HTML to be be output when the requested form is not found. |
get_validation_errors_markup() | Generates the markup for the validation errors list that goes on top of the form. |
get_validation_errors() | Gets a list of validation errors. |
convert_legacy_class() | Convert legacy ready class to the new equivalent. |
validate_form_styles() | Parse and validates styles from the gform_default_styles filter. |
get_form_styles() | Get the form styles from the form parameters and the global style filter. |
get_row_spacer() | Get the spacer to add to the end of the row, if needed |
gform_pre_render() | Filters the $form object through the gform_pre_render filter and caches the result so that this filter is only triggered once per request. |
flush_cached_forms() | Flushes the forms cached by the gform_pre_render method. |
get_confirmation_markup() | |
get_last_page_footer() | Gets the last page's footer markup in a multipage form. |
get_first_page_header() | Gets the first page's header markup in a multipage form. |
Method Reference
process_form()
public static function process_form( $form_id, $initiated_by=self::SUBMISSION_INITIATED_BY_API )
Starting point for the form submission process. Handles the following tasks: Form validation, save for later logic, entry creation, notification and confirmation.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The form ID being submitted. | |
$initiated_by | int | self::SUBMISSION_INITIATED_BY_API | What process initiated the form submission. Possible options are self::SUBMISSION_INITIATED_BY_WEBFORM = 1 or self::SUBMISSION_INITIATED_BY_API = 2. |
Since:
unknown2.6.4(Added the $initiated_by param.)2.10.0(Updated to use GFAPI::send_notification() for the form_saved notification.)
Source: form_display.php:53
maybe_add_review_page()
public static function maybe_add_review_page( $form, $partial_entry=[] )
Get form object and insert review page, if necessary.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object. | |
$partial_entry | array | [] | The partial entry from the resumed incomplete submission. Defaults to an empty array. |
Returns
array— The form object.
Since:
2.1.1.25(Added $partial_entry parameter.)1.9.15
Source: form_display.php:334
get_state()
public static function get_state( $form, $field_values, $additional_values=[] )
Gets the value for the state input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form being prepared for display. | |
$field_values | array | The dynamic population values. | |
$additional_values | array | [] | Additional values to include in the state. |
Returns
string
Since:
unknown3.0(Updated to use the state handler and added the $additional_values param.)
Source: form_display.php:459
get_state_handler()
public static function get_state_handler()
Returns the state handler.
Returns
Form_Display\State\State_Handler
Since: 3.0
Source: form_display.php:470
is_last_page()
public static function is_last_page( $form, $mode='submit' )
Determine if the last page for the current form object is being submitted or rendered (depending on the provided $mode).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | A Gravity Forms form object. | |
$mode | string | 'submit' | Mode to check for: 'submit' or 'render' |
Returns
boolean
Source: form_display.php:673
get_form_theme_slug()
public static function get_form_theme_slug( $form )
Get the slug for the form's theme
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form |
Returns
string— The theme slug
Since: 2.7
Source: form_display.php:745
get_themes_to_enqueue()
public static function get_themes_to_enqueue( $form, $field_types='' )
Determines which themes to enqueue based on the form context and current page.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | Current form object. | |
$field_types | string | array | '' | Optional. If specified, only load themes for forms with fields of these types. Can be a string with a single field type or an array of strings with multiple field types. |
Returns
array|string[]— Returns an array of theme slugs to enqueue
Since: 2.9
Source: form_display.php:801
post_render_script()
public static function post_render_script( $form_id, $current_page='current_page' )
Fire the post render events for a form instance when the form is visible on the page.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | |||
$current_page | 'current_page' |
Returns
string
Since: 2.8.4
Source: form_display.php:837
get_form()
public static function get_form( $form_id, $display_title=true, $display_description=true, $force_display=false, $field_values=null, $ajax=false, $tabindex=0, $form_theme=null, $style_settings=null )
Get a form for display.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The id of the form. | |
$display_title | bool | true | Whether to display the form title. |
$display_description | bool | true | Whether to display the form description. |
$force_display | bool | false | Whether to force the form to display even if it is inactive. |
$field_values | array | null | Array of field values. |
$ajax | bool | false | Whether ajax is enabled. |
$tabindex | int | 0 | Tabindex for the form. |
$form_theme | string | null | Form theme slug. |
$style_settings | string | null | JSON-encoded style settings. Passing false will bypass the gform_default_styles filter. |
Returns
mixed|string| WP_Error
Since:
unknown2.7.15(Added the $form_theme and $style_settings parameters.)
Source: form_display.php:927
get_page()
public static function get_page( $form_id, $page_number, $field_values, $theme, $style_settings, $submission_method )
Get the markup for a specific page in a multipage form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The form ID. | |
$page_number | int | The page number to render. | |
$field_values | array | An array of field values to populate the form with. | |
$theme | string | The current form theme (i.e. orbital or gravity). | |
$style_settings | array | An array of block or shortcode style settings. | |
$submission_method | string | The submission method (i.e. ajax or postback). |
Returns
string— Returns the markup for the specified page of a multipage form.
Since: 2.9.5
Source: form_display.php:1489
get_fields()
public static function get_fields( $form, $field_values, $submitted_values, $page_number=0 )
Get the markup for a colletion of fields in a form. If $page_number is specified, only the markup for the fields on that page will be returned. Otherwise, the markup for all fields in the form will be returned.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current form object. | |
$field_values | array | The array of field values to populate the form with. | |
$submitted_values | array | The array of submitted values if the form has been submitted. | |
$page_number | int | 0 | The current page number to get fields for. Or 0 to get all fields. |
Returns
string— Returns the markup for the specified page of a multipage form, or all fields in the form if no page number is specified.
Since:
2.9.52.9.18(Made the honeypot the first field on the form.)
Source: form_display.php:1543
get_fields_by_page()
public static function get_fields_by_page( $form, $page_number )
Gets the fields for a specific page in a form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form object. | |
$page_number | int | The page number to get fields for. |
Returns
array— Returns an array of fields belonging to the specified page.
Since: 2.9.5
Source: form_display.php:1607
get_submit_button_class()
public static function get_submit_button_class( $button, $form_id )
Get the CSS class for the submit button.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$button | array | The button attributes. | |
$form_id | integer | The ID of the form. |
Returns
string— The CSS class(es) for this button.
Since: 2.6
Source: form_display.php:1722
get_max_field_id()
public static function get_max_field_id( $form )
Get the maximum field ID for the current form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current form object. |
Returns
int
Since:
unknown1.9.14(Updated to public access.)2.4.15(Updated to use GFFormsModel::get_next_field_id().)
Source: form_display.php:1880
is_empty()
public static function is_empty( $field, $form_id=0, $value=self::ARG_NOT_PROVIDED )
Used to determine the required validation result.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field being validated. | |
$form_id | int | 0 | The ID of the form being validated. |
$value | null | string | array | self::ARG_NOT_PROVIDED | The value to validate. Defaults to the GFFormDisplay::ARG_NOT_PROVIDED constant, indicating the value should be retrieved from the $_POST. |
Returns
bool
Since:
unknown3.0(Added the $value param.)
Source: form_display.php:1902
handle_submission()
public static function handle_submission( &$form, &$lead, $ajax=false )
Triggers saving or updating of the entry, spam eval, post creation, sending of notifications, and then returns the confirmation to be used for the current submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$form | array | The form being processed. | |
&$lead | array | The entry being saved. | |
$ajax | bool | false | Indicates if ajax is enabled for the form. |
Returns
string|array
Since:
unknown2.7(Updated the $form param to pass by reference.)
Source: form_display.php:1937
clean_up_files()
public static function clean_up_files( $form, $is_submission=true )
Deletes tmp files for the given form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form the tmp files are to be deleted for. | |
$is_submission | bool | true | Indicates if tmp files for the current form submission should be deletes as well. |
Returns
false|void
Since:
Unknown2.8.15(Added the $is_submission param.)
Source: form_display.php:2126
handle_confirmation()
public static function handle_confirmation( &$form, $entry, $ajax=false, $aux_data=[] )
Prepares the confirmation message or redirect to be used by the current submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$form | array | The Form Object. | |
$entry | array | The Entry Object. | |
$ajax | bool | false | If AJAX is being used. Defaults to false. |
$aux_data | array | [] | Additional data to use when building the confirmation message. Defaults to empty array. |
Returns
string|array
Since:
2.1.1.11(Refactored to use GFFormDisplay::get_confirmation_message().)2.5(Updated to use GFFormDisplay::get_confirmation_url().)2.7(Updated the $form param to pass by reference.)
Source: form_display.php:2196
get_confirmation_url()
public static function get_confirmation_url( $confirmation, $form, $entry )
Returns the redirect URL for the current submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$confirmation | array | The confirmation properties. | |
$form | array | The form which was submitted. | |
$entry | array | The entry created from the form submission. |
Returns
string
Since: 2.5
Source: form_display.php:2270
get_confirmation_message()
public static function get_confirmation_message( $confirmation, $form, $entry, $aux_data=[] )
Gets the confirmation message to be displayed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$confirmation | array | The Confirmation Object. | |
$form | array | The Form Object. | |
$entry | array | The Entry Object. | |
$aux_data | array | [] | Additional data to be passed to GFCommon::replace_variables(). |
Returns
string— The confirmation message.
Since: 2.1.1.11
Source: form_display.php:2328
get_submission_context()
public static function get_submission_context()
Returns the context for the current submission.
Returns
string
Since: 2.6.4
Source: form_display.php:2378
validate()
public static function validate( &$form, $field_values, $page_number=0, &$failed_validation_page=0 )
Determines if the current form submission is valid.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$form | array | The form being processed. | |
$field_values | array | The dynamic population parameter names and values. | |
$page_number | int | 0 | The current page number. |
&$failed_validation_page | int | 0 | The page number which has failed validation. |
Returns
bool
Since:
unknown2.4.19(Updated to use GFFormDisplay::is_field_validation_supported().)
Source: form_display.php:2403
validate_field()
public static function validate_field( $field, $form, $context, $value=self::ARG_NOT_PROVIDED )
Validates the submitted value of the given field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field currently being validated. | |
$form | array | The form currently being validated. | |
$context | string | The context for the current submission. Possible values: form-submit, api-submit, api-validate. | |
$value | null | string | array | self::ARG_NOT_PROVIDED | The value to validate or null to get the value from the $_POST. |
Returns
array
Since:
2.73.0(Added the $value param.)
Source: form_display.php:2599
validate_character_encoding()
public static function validate_character_encoding( $result, $value, $field )
Checks for valid character encoding in the submitted value of the given field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$result | array | { An array containing the validation result properties. | |
$value | mixed | The field value currently being validated. | |
$field | GF_Field | The field currently being validated. |
Returns
array
Since: 2.7.14
Source: form_display.php:2723
is_field_validation_supported()
public static function is_field_validation_supported( $field, $type_check_only=false )
Determines if the supplied field is suitable for validation.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field being processed. | |
$type_check_only | bool | false | Indicates if only the field type property should be evaluated. |
Returns
bool
Since:
2.4.192.4.20(Added the second param.)
Source: form_display.php:2828
is_form_empty()
public static function is_form_empty( $form )
Determines if the current form submission is empty.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form being processed. |
Returns
bool
Since:
unknown2.4.19(Updated to use GFFormDisplay::is_field_validation_supported().)
Source: form_display.php:2848
failed_state_validation()
public static function failed_state_validation( $form_id, $field, $value )
Determines if the field has been tampered with.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | ||
$field | GF_Field | ||
$value | null | string | array |
Returns
bool
Since: unknown
Source: form_display.php:2873
enqueue_scripts()
public static function enqueue_scripts()
Enqueues scripts/styles for forms embedded via blocks and shortcodes.
Since:
unknown2.4.18(Added support for blocks and the gform_post_enqueue_scripts hook.)
Source: form_display.php:2885
parse_forms()
public static function parse_forms( $post_content, &$found_forms, &$found_blocks )
Parses the supplied post content for forms embedded via blocks and shortcodes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_content | string | The post content to be parsed. | |
&$found_forms | array | An array of found forms using the form ID as the key to the ajax status. | |
&$found_blocks | array | An array of found GF blocks. |
Since: 2.4.18
Source: form_display.php:2937
parse_forms_from_blocks()
public static function parse_forms_from_blocks( $blocks, &$found_forms, &$found_blocks )
Finds forms embedded in the supplied blocks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$blocks | array | The blocks found in the post content. | |
&$found_forms | array | An array of found forms using the form ID as the key to the ajax status. | |
&$found_blocks | array | An array of found GF blocks. |
Since: 2.4.18
Source: form_display.php:2960
parse_forms_from_reusable_block()
public static function parse_forms_from_reusable_block( $block, &$found_forms, &$found_blocks )
Finds forms embedded in the supplied reusable block.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$block | array | The block to be processed. | |
&$found_forms | array | An array of found forms using the form ID as the key to the ajax status. | |
&$found_blocks | array | An array of found GF blocks. |
Since: 2.4.18
Source: form_display.php:3011
parse_forms_from_shortcode()
public static function parse_forms_from_shortcode( $post_content, &$found_forms )
Finds forms embedded in the supplied post content.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_content | string | The post content to be processed. | |
&$found_forms | array | An array of found forms using the form ID as the key to the ajax status. |
Since: 2.4.18
Source: form_display.php:3033
is_applicable_form()
public static function is_applicable_form( $form_id, $ajax, $found_forms )
Determines if the supplied form ID should be added to the found forms array.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The form ID to be checked. | |
$ajax | bool | Indicates if Ajax is enabled for the found form. | |
$found_forms | array | An array of found forms using the form ID as the key to the ajax status. |
Returns
bool
Since: 2.4.18
Source: form_display.php:3078
get_embedded_forms()
public static function get_embedded_forms( $post_content, &$ajax )
Returns forms embedded in the supplied post content.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_content | string | The post content to be processed. | |
&$ajax | bool | Indicates if Ajax is enabled for at least one of the forms. |
Returns
array
Since:
unknown2.4.18(Updated to use GFFormDisplay::parse_forms_from_shortcode().)
Source: form_display.php:3093
get_form_enqueue_assets()
public static function get_form_enqueue_assets( $form, $theme=null )
Get the various enqueueable assets for a given form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | An array representing the current Form object. | |
$theme | string | null | The theme slug for the form. |
Returns
Since:
2.52.7(Added $theme parameter)
Source: form_display.php:3122
enqueue_form_scripts()
public static function enqueue_form_scripts( $form, $ajax=false, $theme=null )
Enqueue the required scripts for this form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | An array representing the current Form object. | |
$ajax | false | false | Whether this is being requested via AJAX. |
$theme | string | null | The form theme slug. |
Returns
void
Since: 2.7 (Added the $theme parameter)
Source: form_display.php:3258
add_script_defer()
public static function add_script_defer( $tag, $handle )
Add defer attribute to Gravity Forms scripts and any script dependent on a Gravity Forms script.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$tag | string | The complete script markup that will be output. | |
$handle | string | The handle of the current script. |
Returns
string
Since: 2.5
Source: form_display.php:3299
print_form_scripts()
public static function print_form_scripts( $form, $ajax )
Print the required scripts for this form, since we're hooking in after enqueues have processed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | An array representing the current Form object. | |
$ajax | false | Whether this is being requested via AJAX. |
Returns
void
Source: form_display.php:3327
has_image_choices()
public static function has_image_choices( $form )
Check if a form has any Image Choice fields.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form |
Returns
mixed|null
Since: 2.8
Source: form_display.php:3370
has_page_conditional_logic()
public static function has_page_conditional_logic( $form )
Determines if the form has page conditional logic.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | Form object. |
Returns
bool
Since: 2.5
Source: form_display.php:3429
register_form_init_scripts()
public static function register_form_init_scripts( $form, $field_values=[], $is_ajax=false )
Enqueue and retrieve all inline scripts that should be executed when the form is rendered.
Use add_init_script() function to enqueue scripts.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | ||
$field_values | array | [] | |
$is_ajax | bool | false |
Source: form_display.php:3702
get_counter_init_script()
public static function get_counter_init_script( $form )
Deprecated. No replacement. Text counter settings are rendered as properties to the element in the markup.
To change the counter format, use the gform_text_counter_template filter.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The Form Object |
Returns
string
Since:
Unknown3.0.0(Deprecated. No replacement. Text counter settings are rendered as properties to the element in the markup. To change the counter format, use the gform_text_counter_template filter.)
Source: form_display.php:3881
get_number_formats_script()
public static function get_number_formats_script( $form )
Generates a map of fields IDs and their corresponding number formats used by the GFCalc JS object for correctly
converting field values to clean numbers.
- Number fields have a 'numberFormat' setting (w/ UI).
- Single-input product fields (i.e. 'singleproduct', 'calculation', 'price' and 'hiddenproduct') should default to the number format of the configured currency.
- All other product fields will default to 'decimal_dot' for the number format.
- All other fields will have no format (false) and inherit the format of the formula field when the formula is calculated.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | mixed |
Returns
string
Source: form_display.php:3963
has_field_input_mask()
public static function has_field_input_mask( $field )
Determines if the current field has an input mask.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field to be checked. |
Returns
bool
Source: form_display.php:4187
get_field()
public static function get_field( $field, $value='', $force_frontend_label=false, $form=null, $field_values=null, $page_number=0 )
Gets the markup for a given field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field object. | |
$value | string | '' | The field value to be pre-populated into the field. |
$force_frontend_label | bool | false | Forces the frontend label to be displayed in the admin even if an admin label is configured. Defaults to false. |
$form | array | null | The form object. |
$field_values | array | null | The array of field values used to pre-populate the form. |
$page_number | int | 0 | A non-zero value indicates that only that page should be rendered. This affects how page fields are rendered. Defaults to 0. |
Returns
string|null— Returns the markup for the specified field.
Since: 2.9.5 (Added the optional $page_number parameter.)
Source: form_display.php:4309
get_field_content()
public static function get_field_content( $field, $value='', $force_frontend_label=false, $form_id=0, $form=null )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | ||
$value | string | '' | |
$force_frontend_label | bool | false | |
$form_id | int | 0 | |
$form | null | array | null |
Returns
string
Source: form_display.php:4568
validate_entry_limit()
public static function validate_entry_limit( $form )
Validates the form's entry limit settings. Returns the entry limit message if entry limit exceeded.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | current GF form object |
Returns
string|null— If entry limit exceeded returns entry limit setting.
Source: form_display.php:4711
update_confirmation()
public static function update_confirmation( $form, $entry=null, $event='' )
Populates the form confirmation property with the confirmation to be used for the current submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form being processed. | |
$entry | null | array | null | Null, the entry being processed, or an empty array when the submission fails honeypot validation. |
$event | string | '' | The confirmation event or an empty string. |
Returns
array
Since:
unknown2.10.0(Updated to support using a custom confirmation for spam submissions.)
Source: form_display.php:4792
insert_review_page()
public static function insert_review_page( $form, $review_page )
Insert review page into form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object | |
$review_page | array | The review page |
Returns
array— $form
Since: Unknown
Source: form_display.php:5175
get_anchor()
public static function get_anchor( $form, $ajax )
Get the anchor config for the current form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object. | |
$ajax | bool | Indicates if AJAX is enabled for the current form. |
Returns
array
Since: 2.2.2.1
Source: form_display.php:5218
is_submit_form_id_valid()
public static function is_submit_form_id_valid( $ajax_form_id=null )
Validates the posted input values from the form footer are for the same form, that it exists, is active, and not trashed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$ajax_form_id | null | int | null | Null or the form ID parsed from the gform_ajax input value. |
Returns
bool|int— False or the ID of the form being processed.
Since: 2.4.18
Source: form_display.php:5249
get_submission_method()
public static function get_submission_method( $method='' )
Returns the safe value of/for the gform_submission_method input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$method | string | '' | The method or an empty string to get it from the submission. |
Returns
string
Since: 2.9.2
Source: form_display.php:5287
is_iframe_submission_method()
public static function is_iframe_submission_method()
Determines if the iframe-based Ajax submission method is in use.
Returns
bool
Since: 2.9.2
Source: form_display.php:5306
parse_ajax_input()
public static function parse_ajax_input( $bypass_cache=false )
Parses and sanitizes the value of the gform_ajax input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$bypass_cache | bool | false | Indicates if the cached arguments should be ignored. Default is false. |
Returns
array|false
Since: 2.9.2
Source: form_display.php:5319
prepare_ajax_input_value()
public static function prepare_ajax_input_value( $form_id, $display_title, $display_description, $tabindex, $theme=null, $styles=null, $include_hash=true )
Prepares the value for the gform_ajax input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The form ID. | |
$display_title | bool | Indicates if display of the form title is enabled. | |
$display_description | bool | Indicates if display of the form description is enabled. | |
$tabindex | int | The starting tabindex. | |
$theme | null | string | null | Null or the name of the form theme. |
$styles | null | string | null | Null or the JSON encoded form styles. |
$include_hash | bool | true | Indicates if the hash should be included. |
Returns
string
Since: 2.9.2
Source: form_display.php:5386
get_ajax_postback_html()
public static function get_ajax_postback_html( $body_content )
Returns the HTML for the ajax postback.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$body_content | string | The content to be included in the body of the ajax postback. |
Returns
string
Since: 2.4.18
Source: form_display.php:5413
get_form_not_found_html()
public static function get_form_not_found_html( $form_id, $ajax=false )
Returns the HTML to be be output when the requested form is not found.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | string | The ID or Title of the form requested for display. | |
$ajax | bool | false | Whether to return the html as part of the ajax postback html or on its own. |
Returns
string
Since:
2.5.7(Added the $ajax argument.)2.4.18
Source: form_display.php:5437
get_validation_errors_markup()
public static function get_validation_errors_markup( $form, $values, $show_summary=false )
Generates the markup for the validation errors list that goes on top of the form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | Current form being displayed. | |
$values | array | Submitted values. | |
$show_summary | bool | false | Whether to show a summary of validation errors or just show the validation message. |
Returns
string— Validation errors markup.
Since: 2.5
Source: form_display.php:5464
get_validation_errors()
public static function get_validation_errors( $form, $values )
Gets a list of validation errors.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | Current form being displayed. | |
$values | array | Submitted values. |
Returns
array— List of validation errors for each field, each item contains the error message and its corresponding field label and selector.
Since:
2.52.9.18(Added support for getting the message from the field validation_summary_message context property.)3.0(Updated to support the repeater field.)
Source: form_display.php:5530
convert_legacy_class()
public static function convert_legacy_class( $form, $classes )
Convert legacy ready class to the new equivalent.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current form object. | |
$classes | string | The class or classes to convert. |
Returns
string|void
Since: 2.5
Source: form_display.php:5583
validate_form_styles()
public static function validate_form_styles( $styles )
Parse and validates styles from the gform_default_styles filter.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$styles | mixed | Array or JSON string of styles. |
Returns
array|bool|null— $styles
Since: 2.7.15
Source: form_display.php:5623
get_form_styles()
public static function get_form_styles( $style_settings )
Get the form styles from the form parameters and the global style filter.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$style_settings | array | string | Array or JSON string of styles. |
Returns
array|false|string
Since: 2.7.15
Source: form_display.php:5673
get_row_spacer()
public static function get_row_spacer( $field, $form )
Get the spacer to add to the end of the row, if needed
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | array | The current field object. | |
$form | array | The current form object. |
Returns
string
Since: 2.8.2
Source: form_display.php:5736
gform_pre_render()
public static function gform_pre_render( $form, $context, $ajax=null, $field_values=null )
Filters the $form object through the gform_pre_render filter and caches the result so that this filter is only triggered once per request.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form object being filtered. | |
$context | string | The context that the method is being called in. Possible values are 'form_display' and 'form_config'. | |
$ajax | bool | null | null | Whether the form is being displayed via AJAX. Only used when $context is 'form_display'. |
$field_values | array | null | null | The field values to be used to populate the form. Only used when $context is 'form_display'. |
Returns
array— Returns the form object after being filtered by the gform_pre_render filter.
Since: 2.9.0
Source: form_display.php:5773
flush_cached_forms()
public static function flush_cached_forms( $cache_key=null )
Flushes the forms cached by the gform_pre_render method.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$cache_key | string | null | The cache key to flush. The format is FORM-ID_CONTEXT. Defaults to null and if not provided, all cached forms will be flushed. |
Returns
void
Since: 2.9.0
Source: form_display.php:5804
get_confirmation_markup()
public static function get_confirmation_markup( $form, $confirmation_message, $ajax, $style_settings=false, $form_theme=null )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | ||
$confirmation_message | string | ||
$ajax | bool | ||
$style_settings | false | ||
$form_theme | null |
Returns
mixed
Source: form_display.php:5818
get_last_page_footer()
public static function get_last_page_footer( $form, $label_placement, $ajax, $field_values, $display_title, $display_description, $tabindex, $form_theme, $style_settings, $submission_method )
Gets the last page's footer markup in a multipage form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current form object. | |
$label_placement | string | The label placement setting for the form. | |
$ajax | bool | Indicates if AJAX is enabled for the current form. | |
$field_values | array | The field values to be used to populate the form. | |
$display_title | bool | Indicates if the form title should be displayed. | |
$display_description | bool | Indicates if the form description should be displayed. | |
$tabindex | int | The starting tabindex. | |
$form_theme | string | The theme selected for the form. | |
$style_settings | string | The styles for the form. | |
$submission_method | string | The submission method for the form. |
Returns
string— Returns the markup for the last page's footer.
Since: 2.9.5
Source: form_display.php:5898
get_first_page_header()
public static function get_first_page_header( $form )
Gets the first page's header markup in a multipage form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current form object. |
Returns
string— Returns the markup for the first page's header.
Since: 2.9.5
Source: form_display.php:5924