Skip to content

Commit

Permalink
gpnf-gflow-auto-attach-child-entries.php: Added snippet to Auto-att…
Browse files Browse the repository at this point in the history
…ach Child Entries to Parent when Editing via Gravity Flow.
  • Loading branch information
saifsultanc committed Feb 3, 2025
1 parent 8a2d9f9 commit a8cbf01
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gp-nested-forms/gpnf-gflow-auto-attach-child-entries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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' );
}
return $parent_entry_id;
} );

0 comments on commit a8cbf01

Please sign in to comment.