Skip to content

Commit 39b59c5

Browse files
authored
gpnf-template-singl-submission-child-form.php: Created a new Nested Entries template that only allows a single submission from the child form and heavily customizing the markup.
1 parent e06d738 commit 39b59c5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Nested Forms // Single Submission Child Form
4+
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
5+
*/
6+
add_filter( 'gp_template_output_nested-entries', function( $markup, $located_template, $load, $args ) {
7+
ob_start();
8+
/**
9+
* @var array $nested_fields An array of GF_Field objects.
10+
* @var array $nested_form The form object of the nested form.
11+
* @var array $nested_field_ids An array of nested field IDs.
12+
* @var array $entries An array of child entries submitted from the current Nested Form field.
13+
* @var array $labels An array of labels used in this template.
14+
* @var array $aria_labels An array of labels used for screen readers.
15+
* @var array $actions An array of HTML strings used to display field actions.
16+
* @var bool $enable_duplication Can child entries be duplicated?
17+
* @var int $column_count The number of columns.
18+
* @var string $add_button The markup for the "Add Entry" button.
19+
* @var string $add_button_message The markup for situational messages related to the "Add Entry" button.
20+
*/
21+
extract( $args );
22+
?>
23+
<div class="gpnf-nested-entries-container ginput_container">
24+
25+
<div data-bind="visible: entries().length, foreach: entries">
26+
✅ Child form submitted!
27+
<button class="edit-button" data-bind="click: $parent.editEntry, attr: { 'aria-label': '<?php echo esc_js( $aria_labels['edit_entry'] ); ?>'.format( $index() + 1, f<?php echo $nested_fields[0]['id']; ?>.label ) }"><?php echo $labels['edit_entry']; ?></button>
28+
<button class="delete-button" data-bind="click: $parent.deleteEntry, attr: { 'aria-label': '<?php echo esc_js( $aria_labels['delete_entry'] ); ?>'.format( $index() + 1, f<?php echo $nested_fields[0]['id']; ?>.label ) }"><?php echo $labels['delete_entry']; ?>
29+
</div>
30+
31+
<div data-bind="visible: ! entries().length">
32+
<?php echo $add_button; ?>
33+
<?php echo $add_button_message; ?>
34+
</div>
35+
36+
</div>
37+
<?php
38+
return ob_get_clean();
39+
}, 10, 5 );

0 commit comments

Comments
 (0)