spivurno
12/31/2018 - 7:56 PM

Gravity Perks // GP Nested Forms // Change Submit Button Text for Child Form

Gravity Perks // GP Nested Forms // Change Submit Button Text for Child Form

<?php
/**
 * Gravity Perks // GP Nested Forms // Change Submit Button Text for Child Form
 * http://gravitywiz.com/documentation/gravity-forms-nested-forms/
 */
add_filter( 'gform_pre_render_2', function( $form ) {
	global $wp_current_filter;
	if( ! is_callable( 'gp_nested_forms' ) ) {
		return $form;
	}

	if( gp_nested_forms()->get_posted_entry_id() ) {
		// Submit button text when editing an existing child entry.
		$form['button']['text'] = 'Update Child Entry';
	} else if( in_array( 'gform_get_form_filter', $wp_current_filter ) ) {
		// Submit button text when adding a new child entry.
		$form['button']['text'] = 'Add Child Entry';
	}

	return $form;
} );