Only show child field labels when Nested Form field has no label

Code

Filename: gpnf-export-child-field-header.php

<?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 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.