Set Administrative Field as Summary Field on Entry Detail

Code

Filename: gpnf-set-administrative-summary-field.php

<?php
/**
 * Gravity Perks // Nested Forms // Set Administrative Field as Summary Field on Entry Detail
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 */
// Update "123" to your parent form ID.
add_action( 'gform_admin_pre_render_123', function( $form ) {

	// Update "4" to your Nested Form field ID.
	$nested_form_field_id = 4;
	// Update "5" to your administrative field ID. You can add multiple fields by adding more IDs to the array.
	$add_summary_field_ids = array( 5 );

	if ( GFForms::get_page() !== 'entry_detail' ) {
		return $form;
	}

	foreach ( $form['fields'] as &$field ) {
		if ( $field->id == $nested_form_field_id ) {
			$field->gpnfFields = array_merge( $field->gpnfFields, $add_summary_field_ids );
		}
	}

	return $form;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.