Skip to content

Commit 3e6b6fe

Browse files
committed
gw-advanced-merge-tags.php: Added support for {all_fields} modifier to show data for all entries.
1 parent 2b6afec commit 3e6b6fe

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

gravity-forms/gw-advanced-merge-tags.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,35 @@ public function handle_field_modifiers( $value, $input_id, $modifier, $field, $r
522522
$output .= $all_fields_output;
523523
}
524524

525+
// if no entries were found, return the original value.
526+
$value = $output ? $output : $value;
527+
break;
528+
case 'all_fields':
529+
// Only to be applied for GPPA scenarios, where we may using dynamically populated entry ID data.
530+
if ( ! is_callable( 'gp_populate_anything' ) || ! gp_populate_anything()->is_field_dynamically_populated( $field ) ) {
531+
break;
532+
}
533+
534+
// {all_fields} merge tag support needs to get the entry IDs from the raw value.
535+
$entries = json_decode( $raw_value, true );
536+
537+
// loop through each entry ID and get the {all_fields} output.
538+
$output = '';
539+
foreach ( $entries as $entry_id ) {
540+
$entry = GFAPI::get_entry( $entry_id );
541+
$form = GFAPI::get_form( $entry['form_id'] );
542+
543+
// Safety check: Ensure the entry belongs to the same form as the field.
544+
if ( $field->{'gppa-choices-primary-property'} != $entry['form_id'] ) {
545+
break;
546+
}
547+
548+
// Get the {all_fields} output for each entry.
549+
$all_fields_output = GFCommon::replace_variables( '{all_fields}', $form, $entry, false, false, false );
550+
551+
$output .= $all_fields_output;
552+
}
553+
525554
// if no entries were found, return the original value.
526555
$value = $output ? $output : $value;
527556
break;

0 commit comments

Comments
 (0)