How To Fix Gravity Form Tabindex Conflicts

Avoid the annoying issue where tabbing from a field in one form tabs you to a field in another form. This is caused by conflicting tab indexes.

This is most common when loading a Gravity Form on a page which is loading a non-GF form (like the WordPress comment form). You’re typing away on your Gravity Form and tab to the next field. Awesome. Except the next field is a completely different form. This snippet sets the starting index of your Gravity Form inputs ridiculously high so such conflicts never happen again.

<?php
/**
 * Fix Gravity Form Tabindex Conflicts
 * http://gravitywiz.com/fix-gravity-form-tabindex-conflicts/
 */
add_filter( 'gform_tabindex', 'gform_tabindexer', 10, 2 );
function gform_tabindexer( $tab_index, $form = false ) {
    $starting_index = 1000; // if you need a higher tabindex, update this number
    if( $form )
        add_filter( 'gform_tabindex_' . $form['id'], 'gform_tabindexer' );
    return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
}
?>