Skip to content

Instantly share code, notes, and snippets.

@chrisegg
Created March 21, 2022 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisegg/afc77d09c86342028df1d34079c5c068 to your computer and use it in GitHub Desktop.
Save chrisegg/afc77d09c86342028df1d34079c5c068 to your computer and use it in GitHub Desktop.
<?php
/**
*
* GravityRanger // Gravity Forms Reset Button
* https://gravityranger.com/gravity-forms-reset-button/
*
* Use this code snippet to add a reset button to your forms.
* Code snippet will add the button to all forms by default.
*
* Instructions:
*
* 1. Copy and paste the snippet into your themes functions.php file or use a functionality plugin like WPCodeBox
* 2. Add your form ID to the filter if you only want to add the button to one form (i.e gform_submit_button_ID)
* 3. Option: You can change the value (line31) to whatever you'd like (value="Button Text")
*
* Known Limitations:
*
* 1. It does not work on all pages in a multi-page forms
* 2. It will not clear fields populated dynamically
* 3. It will not clear a Product field that uses the Calculation field type
*
*
* @author Chris Eggleston
* @link https://gravityranger.com/
*
*/
add_filter( 'gform_submit_button', 'form_reset_button', 10, 2 );
function form_reset_button( $button, $form ) {
$button .= '<input type="reset" value="Reset Form">';
return $button;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment