Using Gravity Forms ‘gform_tabindex’ PHP filter

The gform_tabindex filter allows you to modify the tabindex attribute for form fields in Gravity Forms.

Usage

To change the tabindex for a specific form:

add_filter('gform_tabindex_5', 'my_custom_tabindex', 10, 2);
function my_custom_tabindex($tabindex, $form) {
    // your custom code here
    return $new_tabindex;
}

Parameters

  • $tabindex (string): The current tabindex value.
  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_tabindex

Important: Modifying the tabindex can impact accessibility. We recommend allowing the browser to determine the tabindex for your page.

Examples

Disable tabindex for all forms

Disable the tabindex attribute for all forms:

add_filter('gform_tabindex', '__return_false');

Disable tabindex for a specific form

Disable the tabindex attribute for form with ID 5:

add_filter('gform_tabindex_5', '__return_false');

Change tabindex start value for a specific form

Change the tabindex start value to 4 for form with ID 10:

add_filter('gform_tabindex_10', 'change_tabindex', 10, 2);
function change_tabindex($tabindex, $form) {
    return 4;
}

Increment tabindex by 10 for a specific form

Increment the tabindex values by 10 for form with ID 7:

add_filter('gform_tabindex_7', 'increment_tabindex_by_10', 10, 2);
function increment_tabindex_by_10($tabindex, $form) {
    return intval($tabindex) + 10;
}

Set tabindex to a fixed value for a specific form

Set the tabindex value to 100 for form with ID 12:

add_filter('gform_tabindex_12', 'set_fixed_tabindex', 10, 2);
function set_fixed_tabindex($tabindex, $form) {
    return 100;
}