gp_template_output
Description
Filter the output of the located template.
Usage
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' );Parameters
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.
Since
This filter is available since Gravity Forms Nested Forms 1.1.15.
Examples
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Gravity Perks // Nested Forms // Hide Nested Entries Table if Empty
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gp_template_output_nested-entries', function( $markup, $located_template, $load, $args ) {
ob_start();
/**
* @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">
<thead>
<tr>
<?php foreach ( $nested_fields as $nested_field ) : ?>
<th class="gpnf-field-<?php echo $nested_field['id']; ?>">
<?php echo GFCommon::get_label( $nested_field ); ?>
</th>
<?php endforeach; ?>
<th class="gpnf-row-actions"><span class="screen-reader-text"><?php esc_html_e( 'Actions', 'gp-nested-forms' ); ?></span></th>
</tr>
</thead>
<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 ); ?>"
> </td>
<?php endforeach; ?>
<td class="gpnf-row-actions" style="display: none;" data-bind="visible: true">
<ul>
<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>
</ul>
</td>
</tr>
</tbody>
</table>
<?php echo $add_button; ?>
<?php echo $add_button_message; ?>
</div>
<?php
return ob_get_clean();
}, 10, 5 );All Connections
All Perks
- GF Address Autocomplete
- GF Advanced Calculations
- GF Advanced Phone Field
- GF Advanced Save & Continue
- GF Advanced Select
- GF Auto List Field
- GF Auto Login
- GF Better User Activation
- GF Blocklist
- GF Bookings
- GF Conditional Logic Dates
- GF Conditional Pricing
- GF Copy Cat
- GF Date Time Calculator
- GF Disable Entry Creation
- GF Easy Passthrough
- GF eCommerce Fields
- GF Email Users
- GF Email Validator
- GF Entry Blocks
- GF Expand Textareas
- GF File Renamer
- GF File Upload Pro
- GF Inventory
- GF Limit Checkboxes
- GF Limit Dates
- GF Limit Submissions
- GF Live Preview
- GF Media Library
- GF Multi-Page Navigation
- GF Nested Forms
- GF Notification Scheduler
- GF Page Transitions
- GF Pay Per Word
- GF Populate Anything
- GF Post Content Merge Tags
- GF Preview Submission
- GF Price Range
- GF QR Code
- GF Randomizer
- GF Read Only
- GF Reload Form
- GF Submit to Access
- GF Terms Of Service
- GF Unique ID
- GF Word Count