Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpnf-admin-merge-tag-modifier-template.php: Migrated from `experimental folder. #991

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions gp-nested-forms/gpnf-admin-merge-tag-modifier-template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Allow :admin modifier in {all_fields} merge tag to affect displayed nested form.
* IMPORTANT: Make sure the file name is "nested-entries-detail.php".
* Usage: Place this file in your current active theme structure.
*
* Experimental Snippet 🧪
*
* @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 $actions An array of HTML strings used to display field actions.
* @var array $args An array of arguments passed to the template.
*/
?>
<div class="gpnf-nested-entries-container gpnf-entry-view ginput_container">

<table class="gpnf-nested-entries">

<thead>
<tr>
<?php foreach ( $nested_fields as $nested_field ) : ?>
<th class="gpnf-field-<?php echo $nested_field['id']; ?>">
<?php
if ( rgar( $args, 'modifiers' ) && strpos( $args['modifiers'], 'admin' ) !== false ) {
$nested_field->set_context_property( 'use_admin_label', true );
}
?>
<?php echo GFCommon::get_label( $nested_field ); ?>
</th>
<?php endforeach; ?>
<th class="gpnf-row-actions">&nbsp;</th>
</tr>
</thead>

<tbody>
<?php foreach ( $entries as $entry ) : ?>
<?php $field_values = gp_nested_forms()->get_entry_display_values( $entry, $nested_form, $nested_field_ids ); ?>
<tr>
<?php
foreach ( $nested_fields as $nested_field ) :
$field_value = rgars( $field_values, "{$nested_field['id']}/label" );
?>
<td class="gpnf-field"
data-heading="<?php echo GFCommon::get_label( $nested_field ); ?>"
data-value="<?php echo esc_attr( $field_value ); ?>">
<?php echo $field_value; ?>
</td>
<?php endforeach; ?>
<!-- The whitespace below matters. Using CSS :empty to hide when link is not output. -->
<td class="gpnf-row-actions"><?php if ( ! empty( $labels['view_entry'] ) ) : ?>
<a href="<?php echo gp_nested_forms()->get_entry_url( $entry['id'], $nested_form['id'] ); ?>">
<?php echo $labels['view_entry']; ?>
</a>
<?php endif; ?></td>
</tr>
<?php endforeach; ?>
</tbody>

</table>

<div class="gpnf-actions">
<?php echo implode( ' | ', $actions ); ?>
</div>

</div>
Loading