Using Gravity Forms ‘gform_column_input’ PHP filter

The gform_column_input Gravity Forms PHP filter allows you to change the input type for a specific column in a list field. Supported input types include “select” (Drop Down) and “text” (Text Field).

Usage

To apply the filter to a specific column, use the following format:

add_filter('gform_column_input_FORMID_FIELDID_COLUMN', 'your_custom_function', 10, 5);

Parameters

  • $input_info (array): The input information array to be filtered.
  • $field (Field Object): The current field.
  • $column (string): The current column name.
  • $value (string): The currently entered or selected value for the column’s input.
  • $form_id (integer): ID of the current form.

More information

See Gravity Forms Docs: gform_column_input

Examples

Change the input type of a specific column to a drop-down

This example changes column 1 of list field 2 in a form with ID 187 to a drop-down.

add_filter('gform_column_input_187_2_1', 'set_column', 10, 5);

function set_column($input_info, $field, $column, $value, $form_id) {
    return array('type' => 'select', 'choices' => 'First Choice,Second Choice');
}

Change the input type of a specific column to a drop-down with specified values

This example changes column 1 of list field 2 in a form with ID 187 to a drop-down with specified values.

add_filter('gform_column_input_187_2_1', 'set_column_with_values', 10, 5);

function set_column_with_values($input_info, $field, $column, $value, $form_id) {
    return array(
        'type' => 'select',
        'choices' => array(
            array('text' => 'First Choice', 'value' => 'First'),
            array('text' => 'Second Choice', 'value' => 'Second')
        )
    );
}

Change the input type of a specific column to a text field

This example changes column 2 of list field 3 in a form with ID 187 to a text field.

add_filter('gform_column_input_187_3_2', 'set_text_column', 10, 5);

function set_text_column($input_info, $field, $column, $value, $form_id) {
    return array('type' => 'text');
}

Change the input type based on the column name

This example changes the input type to a drop-down for columns named “Category” in list field 4 of a form with ID 187.

add_filter('gform_column_input_187_4', 'set_column_based_on_name', 10, 5);

function set_column_based_on_name($input_info, $field, $column, $value, $form_id) {
    if ($column === 'Category') {
        return array('type' => 'select', 'choices' => 'Option A,Option B,Option C');
    }
    return $input_info;
}