Using Gravity Forms ‘gform_form_args’ PHP filter

The gform_form_args filter in Gravity Forms allows you to modify the options used to display a form.

Usage

add_filter('gform_form_args', 'your_function_name', 10, 1);

Parameters

  • $form_args (array): An array of Form Arguments when adding it to a page/post. Possible values in the array:
    • form_id – the form id or title
    • display_title – true/false
    • display_description – true/false
    • force_display – true/false
    • field_values – An array of dynamic population parameter keys with their corresponding values to be populated.
    • ajax – true/false
    • tabindex – number

More information

See Gravity Forms Docs: gform_form_args

Examples

Hide form title

To hide the form title, set the display_title to false.

add_filter('gform_form_args', 'hide_form_title');
function hide_form_title($form_args) {
    $form_args['display_title'] = false;
    return $form_args;
}

Show form description

To show the form description, set the display_description to true.

add_filter('gform_form_args', 'show_form_description');
function show_form_description($form_args) {
    $form_args['display_description'] = true;
    return $form_args;
}

Force form display

To force the form to display, even if it has already been submitted, set the force_display to true.

add_filter('gform_form_args', 'force_form_display');
function force_form_display($form_args) {
    $form_args['force_display'] = true;
    return $form_args;
}

Enable AJAX for the form

To enable AJAX for the form, set the ajax to true.

add_filter('gform_form_args', 'enable_ajax');
function enable_ajax($form_args) {
    $form_args['ajax'] = true;
    return $form_args;
}

Set tabindex for the form

To set the tabindex for the form, provide a number for the tabindex.

add_filter('gform_form_args', 'set_form_tabindex');
function set_form_tabindex($form_args) {
    $form_args['tabindex'] = 10;
    return $form_args;
}