Disable Modal Cancel Confirmation

This snippet removes the confirmation prompt when canceling a Nested Form modal. Normally, when a user attempts to close the modal without saving, they are asked to confirm their action. With this snippet, the modal closes immediately.

Instructions

Code

Filename: gpnf-disable-modal-cancel-confirmation.php

<?php
/**
 * Gravity Perks // Nested Forms // Disable Modal Cancel Confirmation
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * This snippet removes the confirmation prompt when canceling a Nested Form modal. 
 * Normally, when a user attempts to close the modal without saving, they are asked 
 * to confirm their action. With this snippet, the modal closes immediately.
 *
 * Instructions:
 *
 * 1. Install this snippet.
 *    https://gravitywiz.com/documentation/managing-snippets/#where-do-i-put-snippets
 */
add_filter( 'gpnf_init_script_args', function( $args, $field, $form ) {
	$args['modalLabels']['confirmAction'] = false;
	return $args;
}, 10, 3 );

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.