Require Confirmation to Delete Child Entry on Parent Form

Require users to confirm delection of a child entry on the parent form. This works the same was as the confirm-to-delete requirement in the child form.

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/

Code

Filename: gpnf-require-confirm-to-delete-on-parent-form.js

/**
 * Gravity Perks // Nested Forms // Require Confirmation to Delete Child Entry on Parent Form
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Require users to confirm delection of a child entry on the parent form. This works the same was as the
 * confirm-to-delete requirement in the child form.
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
window.gform.addFilter( 'gpnf_should_delete', function( shouldDelete, items, $trigger, gpnf ) {
	if ( ! $trigger.is('.gpnf-row-actions .delete-button') ) {
		return shouldDelete;
	}
	if ( ! $trigger.data( 'isConfirming' ) ) {
		$trigger
			.data( 'isConfirming', true )
			.text( gpnf.modalArgs.labels.confirmAction );
		setTimeout( function() {
			$trigger
				.data( 'isConfirming', false )
				.text( gpnf.modalArgs.labels.delete );
		}, 3000 );

		return false;
	}
	return shouldDelete;
} );

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.