Description
Filter whether the child entry should be deleted. Useful for adding custom confirmations before deleting.
Usage
gform.addFilter( 'gpnf_should_delete', 'my_custom_function' );
Parameters
shouldDelete boolean
Whether the child entry should be deleted. Defaults to
true
.item object
The child entry being deleted.
$trigger JQuery
The element that triggered the deletion.
gpnf GPNestedForms
Current instance of the GPNestedForms object.
Examples
Add confirmation to Delete buttons in the parent form
This snippet adds a confirmation to the Delete buttons in the parent form much like the confirmation when deleting from the Edit modal.
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;
});
Since
This filter is available since Gravity Forms Nested Forms 1.0-rc-1.10.