gpnf_export_child_field_header
Description
Modify the header label for the current child field.
Usage
Apply to all child fields for all Nested Form fields on all forms.
add_filter( 'gpnf_export_child_field_header', 'my_custom_function' );
Apply to all child fields for all Nested Forms fields on a specific form.
add_filter( 'gpnf_export_child_field_header_FORMID', 'my_custom_function' );
Apply to all child fields for a specific Nested Form field on a specific form.
add_filter( 'gpnf_export_child_field_header_FORMID_FIELDID', 'my_custom_function' );
Parameters
header string
The default header label.
form array
The current form object.
field \GF_Field
The current Nested Form field.
child_field \GF_Field
The current child field.
Examples
Only show child field labels when Nested Form field has no label
If the Nested Form field has no label, the default output might look something like / Child field label
. This snippet will update that to Child field label
(no slash).
<?php
/**
* Gravity Perks // Nested Forms // Only show child field labels when Nested Form field has no label
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gpnf_export_child_field_header', function( $header, $form, $field, $child_field ) {
$parent_label = $field->get_field_label( false, null );
if ( empty( $parent_label ) ) {
$header = $child_field->get_field_label( false, null );
} else {
$header = sprintf( '%s / %s', $parent_label, $child_field->get_field_label( false, null ) );
}
return $header;
}, 10, 4 );