Auto-attach Child Entries to Parent when Editing via Gravity Flow.

By default, when adding a new child entry to a Nested Form field while editing a parent entry via Gravity Flow, the child entry is saved to the session and will not be attached to the parent entry unless you click “Submit” on the workflow.

Use this snippet to automatically attach the child entry to the parent as soon as the child form is submitted.

Code

Filename: gpnf-gflow-auto-attach-child-entries.php

<?php
/**
 * Gravity Perks // Nested Forms // Auto-attach Child Entries to Parent when Editing via Gravity Flow.
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * By default, when adding a new child entry to a Nested Form field while editing a parent entry via Gravity Flow, the
 * child entry is saved to the session and will not be attached to the parent entry unless you click "Submit" on the
 * workflow.
 *
 * Use this snippet to automatically attach the child entry to the parent as soon as the child form is submitted.
 */
add_filter( 'gpnf_set_parent_entry_id', function( $parent_entry_id ) {
	if ( ! $parent_entry_id && is_callable( 'gravity_flow' ) && gravity_flow()->is_workflow_detail_page() ) {
		$parent_entry_id = rgget( 'lid' ) ? rgget( 'lid' ) : $parent_entry_id;
	}
	return $parent_entry_id;
} );

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.