gpnf_template_args
Description
Filter the arguments that will be used to render the Nested Form field template.
Usage
Apply to all applicable fields on all forms.
add_filter( 'gpnf_template_args', 'my_custom_function' );
Apply to all applicable fields on a specific form.
add_filter( 'gpnf_template_args_FORMID', 'my_custom_function' );
Apply to a specific field on a specific form.
add_filter( 'gpnf_template_args_FORMID_FIELDID', 'my_custom_function' );
Parameters
args array
The following properties are passed in the $args array.
template string
The template file to be rendered.
field GP_Field_Nested_Form
The current Nested Form field.
nested_form array
The nested form object for the current Nested Form field.
nested_fields array
Any array of field objects on the nested form that will be displayed on the parent entry.
nested_field_ids array
The field IDs from the nested form that will be displayed on the parent entry.
column_count int
The number of columns (based on $nested_field_ids count plus one for the actions column).
value string
A comma-delimited list of entry IDs that have been submitted for this Nested Form field and parent entry.
entries array
An array of entries that have been submitted for this Nested Form field and parent entry.
add_button string
An HTML button that allows users to load the nested form modal and add new entries to the Nested Form field.
add_button_message string
HTML message that shows when the max number of entries has been met.
tabindex string
The Gravity Forms tabindex string, if tabindex is enabled.
actions string
An array of HTML links to be output as action items for the child entry list.
labels array
An array of miscellaneous UI labels that will be used when rendering the template.
field GP_Field_Nested_Form
The current Nested Form field
Since
This filter is available since GP Nested Forms 1.0.
Examples
Change template for GravityView Entry List view.
Change the template of the Nested Form field to use the nested-entries-detail-simple
template when viewed in GravityView’s Entry List view. This template will hide the View, Edit and View All Entries links that appear in the default nested-entries-detail
view.
<?php
/**
* Gravity Perks // Nested Forms // Change Template for GravityView Entry List View
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
// Update "123" to your form ID and "4" to your field ID.
add_filter( 'gpnf_template_args_123_4', function ( $args, $field ) {
if ( gravityview()->request->is_view() && ( ! gravityview()->request->is_entry() || ! gravityview()->request->is_edit_entry() ) ) {
// Specify the template you would like to use.
$args['template'] = 'nested-entries-detail-simple';
}
return $args;
}, 10, 2 );