Gravity Forms

Gravity Forms Logging

File is located in /tools:

TF gflogging_example.php: include this file to log Gravity Forms notices and errors to debug.log (Note: newer versions of GF may have this better integrated.

prevent page scrolling on submit

  1. // prevents page scrolling on both form submission and moving between pages in ajax mode
  2. // old way add_filter("gform_confirmation_anchor", create_function("","return false;"));
  3. add_filter( 'gform_confirmation_anchor', '__return_false' );
// prevents page scrolling on both form submission and moving between pages in ajax mode
// old way add_filter("gform_confirmation_anchor", create_function("","return false;"));
add_filter( 'gform_confirmation_anchor', '__return_false' );

Custom AJAX Spinners

  1. add_filter( 'gform_ajax_spinner_url', 'custom_gforms_spinner' );
  2. function custom_gforms_spinner( $src ) {
  3. // note: there is a set of spinner choices in /images
  4. // make more at http://www.ajaxload.info
  5.  
  6. // example of different spinners on different pages
  7.         if($_SERVER["REQUEST_URI"] == "/")
  8.             return get_stylesheet_directory_uri() . '/images/ajax-spinner-white-on-blue.gif';
  9.         else
  10.             return get_stylesheet_directory_uri() . '/images/ajax-spinner-blue.gif';
  11. }
add_filter( 'gform_ajax_spinner_url', 'custom_gforms_spinner' );
function custom_gforms_spinner( $src ) {
// note: there is a set of spinner choices in /images
// make more at http://www.ajaxload.info

// example of different spinners on different pages
        if($_SERVER["REQUEST_URI"] == "/")
            return get_stylesheet_directory_uri() . '/images/ajax-spinner-white-on-blue.gif';
        else
            return get_stylesheet_directory_uri() . '/images/ajax-spinner-blue.gif';
}

Available Spinners

make more at http://www.ajaxload.info

images/ajax-spinner-white-on-blue.gif

images/ajax-spinner-white-on-red.gif

images/ajax-spinner-red.gif

images/ajax-spinner-blue.gif

Clear Input Box on Focus

  1. // clears input box on focus in gravity form
  2. jQuery(document).ready(function() {
  3.     jQuery.fn.cleardefault = function() {
  4.         return this.focus(function() {
  5.             if( this.value == this.defaultValue ) {
  6.                 this.value = "";
  7.                 }
  8.             }).blur(function() {
  9.             if( !this.value.length ) {
  10.                 this.value = this.defaultValue;
  11.             }
  12.         });
  13.     };
  14.     jQuery(".clearit input, .clearit textarea").cleardefault();
  15. });
// clears input box on focus in gravity form
jQuery(document).ready(function() {
    jQuery.fn.cleardefault = function() {
        return this.focus(function() {
            if( this.value == this.defaultValue ) {
                this.value = "";
                }
            }).blur(function() {
            if( !this.value.length ) {
                this.value = this.defaultValue;
            }
        });
    };
    jQuery(".clearit input, .clearit textarea").cleardefault();
});