1. Description
  2. Usage
  3. Parameters
  4. Since
  5. Examples
    1. Hide Entries Table if Empty


Filter the output of the located template.


Filter output for all Nested Forms templates.

add_filter( 'gp_template_output', 'my_custom_function' );

Filter output for a specific Nested Forms template.

add_filter( 'gp_template_output_TEMPLATE', 'my_custom_function' );


  • output string

    The output of the located template.

  • located_template string

    The path to the located template.

  • load bool

    Whether the template should be loaded.

  • args array

    The arguments passed to the template.


This filter is available since Gravity Forms Nested Forms 1.1.15.


Hide Entries Table if Empty

This example filters the nested-entries.php to hide the Entries Table if no child child entries have been added. The table will appear as soon as the first child entry is added and disappear if all child entries are deleted.

 * Gravity Perks // Nested Forms // Hide Nested Entries Table if Empty
add_filter( 'gp_template_output_nested-entries', function( $markup, $located_template, $load, $args ) {
	 * @var array  $nested_fields      An array of GF_Field objects.
	 * @var array  $nested_form        The form object of the nested form.
	 * @var array  $nested_field_ids   An array of nested field IDs.
	 * @var array  $entries            An array of child entries submitted from the current Nested Form field.
	 * @var array  $labels             An array of labels used in this template.
	 * @var array  $aria_labels        An array of labels used for screen readers.
	 * @var array  $actions            An array of HTML strings used to display field actions.
	 * @var bool   $enable_duplication Can child entries be duplicated?
	 * @var int    $column_count       The number of columns.
	 * @var string $add_button         The markup for the "Add Entry" button.
	 * @var string $add_button_message The markup for situational messages related to the "Add Entry" button.
	extract( $args );
	<div class="gpnf-nested-entries-container ginput_container">

		<table class="gpnf-nested-entries" data-bind="visible: entries().length">

				<?php foreach ( $nested_fields as $nested_field ) : ?>
					<th class="gpnf-field-<?php echo $nested_field['id']; ?>">
						<?php echo GFCommon::get_label( $nested_field ); ?>
				<?php endforeach; ?>
				<th class="gpnf-row-actions"><span class="screen-reader-text"><?php esc_html_e( 'Actions', 'gp-nested-forms' ); ?></span></th>

			<tbody data-bind="visible: entries().length, foreach: entries">
			<tr data-bind="attr: { 'data-entryid': id }">
				<?php foreach ( $nested_fields as $nested_field ) : ?>
					<td class="gpnf-field"
						data-bind="html: f<?php echo $nested_field['id']; ?>.label, attr: { 'data-value': f<?php echo $nested_field['id']; ?>.label }"
						data-heading="<?php echo GFCommon::get_label( $nested_field ); ?>"
				<?php endforeach; ?>
				<td class="gpnf-row-actions" style="display: none;" data-bind="visible: true">
						<li class="edit"><button class="edit-button" data-bind="click: $parent.editEntry, attr: { 'aria-label': '<?php echo esc_js( $aria_labels['edit_entry'] ); ?>'.gformFormat( $index() + 1, f<?php echo $nested_fields[0]['id']; ?>.label ) }"><?php echo $labels['edit_entry']; ?></button></li>
						<?php if ( $enable_duplication ) : ?>
							<li class="duplicate" data-bind="visible: ! $parent.isMaxed()"><button href="#" data-bind="click: $parent.duplicateEntry, attr: { 'aria-label': '<?php echo esc_js( $aria_labels['duplicate_entry'] ); ?>'.gformFormat( $index() + 1, f<?php echo $nested_fields[0]['id']; ?>.label ) }"><?php echo $labels['duplicate_entry']; ?></button></li>
						<?php endif; ?>
						<li class="delete"><button class="delete-button" data-bind="click: $parent.deleteEntry, attr: { 'aria-label': '<?php echo esc_js( $aria_labels['delete_entry'] ); ?>'.gformFormat( $index() + 1, f<?php echo $nested_fields[0]['id']; ?>.label ) }"><?php echo $labels['delete_entry']; ?></button></li>


		<?php echo $add_button; ?>
		<?php echo $add_button_message; ?>

	return ob_get_clean();
}, 10, 5 );