Skip to content

Commit b6ed5b9

Browse files
authored
gpnf-admin-merge-tag-modifier-template.php: Migrated from experimental folder.
1 parent 56e6249 commit b6ed5b9

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Allow :admin modifier in {all_fields} merge tag to affect displayed nested form.
4+
* IMPORTANT: Make sure the file name is "nested-entries-detail.php".
5+
* Usage: Place this file in your current active theme structure.
6+
*
7+
* Experimental Snippet 🧪
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 $actions An array of HTML strings used to display field actions.
15+
* @var array $args An array of arguments passed to the template.
16+
*/
17+
?>
18+
<div class="gpnf-nested-entries-container gpnf-entry-view ginput_container">
19+
20+
<table class="gpnf-nested-entries">
21+
22+
<thead>
23+
<tr>
24+
<?php foreach ( $nested_fields as $nested_field ) : ?>
25+
<th class="gpnf-field-<?php echo $nested_field['id']; ?>">
26+
<?php
27+
if ( rgar( $args, 'modifiers' ) && strpos( $args['modifiers'], 'admin' ) !== false ) {
28+
$nested_field->set_context_property( 'use_admin_label', true );
29+
}
30+
?>
31+
<?php echo GFCommon::get_label( $nested_field ); ?>
32+
</th>
33+
<?php endforeach; ?>
34+
<th class="gpnf-row-actions">&nbsp;</th>
35+
</tr>
36+
</thead>
37+
38+
<tbody>
39+
<?php foreach ( $entries as $entry ) : ?>
40+
<?php $field_values = gp_nested_forms()->get_entry_display_values( $entry, $nested_form, $nested_field_ids ); ?>
41+
<tr>
42+
<?php
43+
foreach ( $nested_fields as $nested_field ) :
44+
$field_value = rgars( $field_values, "{$nested_field['id']}/label" );
45+
?>
46+
<td class="gpnf-field"
47+
data-heading="<?php echo GFCommon::get_label( $nested_field ); ?>"
48+
data-value="<?php echo esc_attr( $field_value ); ?>">
49+
<?php echo $field_value; ?>
50+
</td>
51+
<?php endforeach; ?>
52+
<!-- The whitespace below matters. Using CSS :empty to hide when link is not output. -->
53+
<td class="gpnf-row-actions"><?php if ( ! empty( $labels['view_entry'] ) ) : ?>
54+
<a href="<?php echo gp_nested_forms()->get_entry_url( $entry['id'], $nested_form['id'] ); ?>">
55+
<?php echo $labels['view_entry']; ?>
56+
</a>
57+
<?php endif; ?></td>
58+
</tr>
59+
<?php endforeach; ?>
60+
</tbody>
61+
62+
</table>
63+
64+
<div class="gpnf-actions">
65+
<?php echo implode( ' | ', $actions ); ?>
66+
</div>
67+
68+
</div>

0 commit comments

Comments
 (0)