gpnf_init_script_args

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Change Modal Title and Submit Button
  5. Since

Description

Filter the arguments that will be used to initialized the nested forms frontend script.

Usage

Filter applied globally to all forms and fields

add_filter( 'gpnf_init_script_args', 'my_custom_function' );

Filter applied to all fields for a specific form

add_filter( 'gpnf_init_script_args_FORMID', 'my_custom_function' );

Filter applied to a specific form and field

add_filter( 'gpnf_init_script_args_FORMID_FIELDID', 'my_custom_function' );

Parameters

$args array

The arguments that will be used to initialized the nested forms frontend script.

formId int

The current form ID.

fieldId int

The field ID of the Nested Form field.

nestedFormId int

The form ID of the nested form.

displayFields array

The fields which will be displayed in the Nested Forms entries view.

entries array

An array of modified entries, including only their display values.

ajaxUrl string

The URL to which AJAX requests will be posted.

modalLabels array

The labels for the modal.

title string

The title to be displayed in the modal header.

editTitle string

The title to be displayed in the modal header when editing an existing entry.

submit string|false

The text to be displayed inside Submit button.

editSubmit string|false

The text to be displayed inside Submit button when editing an entry.

cancel string

The text to be displayed inside Cancel button.

delete string

The text to be displayed inside Delete button.

confirmAction string

The question to be displayed when confirming an action.

closeScreenReaderLabel string

The close button label for screen readers.

modalColors array

The colors for the modal.

primary string

A HEX color that will be set as the default background color of the Add and Edit Entry buttons.

secondary string

A HEX color that will be set as the default background color for Cancel button.

danger string

A HEX color that will be set as the default background color for Delete and Are you sure? buttons.

modalHeaderColor string

A HEX color that will be set as the default background color of the modal header.

modalClass string

The class that will be attached to the modal for styling.

modalStickyFooter bool

Whether the footer should stick to the bottom of the modal.

entryLimitMin int

The minimum number of entries that can be submitted for this field.

entryLimitMax int

The maximum number of entries that can be submitted for this field.

sessionData array

Default session data for the field.

spinnerUrl string

The URL to the loading spinner image.

modalTitle string

The title to be displayed in the modal header (deprecated).

editModalTitle string

The title to be displayed in the modal header when editing an existing entry (deprecated).

modalWidth int

The default width of the modal; defaults to 700.

modalHeight string|int

The default height of the modal; defaults to ‘auto’ which will automatically size the modal based on its contents.

hasConditionalLogic bool

Indicate whether the current form has conditional logic enabled.

isGF25 bool

Whether Gravity Forms version is 2.5 or higher.

enableFocusTrap bool

Whether the nested form should use a focus trap when open to prevent tabbing outside the nested form.

ajaxContext array

Context data for AJAX requests including post_id, path, field_values, and request.

$field GF_Field

The current Nested Form field.

$form array

The current form.

Examples

Change Modal Title and Submit Button

By default, the submit button label will be the same as the modal title, “Add {Item}” and “Edit {Item}” respectively. Use this snippet to change the title and submit button labels for both the Add and Edit modals.

<?php
/**
 * Gravity Perks // Nested Forms // Change Modal Title and Submit Button
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 */
// Update "123" to your form ID and "4" to your Nested Form field ID.
add_filter( 'gpnf_init_script_args_123_4', function( $args ) {
	$args['modalLabels']['title']      = 'Create New Child Entry';
	$args['modalLabels']['editTitle']  = 'Edit Child Entry';
	$args['modalLabels']['submit']     = 'Submit';
	$args['modalLabels']['editSubmit'] = 'Edit';
	return $args;
} );

By default, the Nested Forms field modal has “sticky” footer. It will keep the footer visible on longer forms by sticking it to the bottom of the screen. Use this snippet to “unstick” the footer and it will appear at the bottom of the form.

<?php
/**
 * Gravity Perks // Nested Forms // Unstick the Modal Footer
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 */
add_filter( 'gpnf_init_script_args', function( $args ) {
	$args['modalStickyFooter'] = false;
	return $args;
} );

Since

  • 1.0 Hook added.