gform_column_input

Description

This filter can be used to specify a different input type for a list field column. Currently supported field types are “select” (Drop Down) and “text” (Text Field)

Usage

add_filter( 'gform_column_input', 'set_column_input', 10, 5 );

You can also target a specific column by adding the form id, field id and column number after the hook name. (format: gform_column_input_FORMID_FIELDID_COLUMN)

//This filter declaration targets the first column of field whose id is 2 in form whose id is 6
add_filter( 'gform_column_input_6_2_1', 'set_column_input', 10, 5 );

Parameters

  • $input_info array

    The input info array to be filtered, in the following format:

  • array(
    	'type'    => 'select',
    	'choices' => 'First Choice,Second Choice',
    );
    
    // OR, if values need to be specified for each choice, the following format can also be used:
    array(
    	'type'    => 'select',
    	'choices' => array(
    		array( 'text' => 'First Choice', 'value' => 'First' ),
    		array( 'text' => 'Second Choice', 'value' => 'Second' ),
    	),
    );
    
  • $field Field Object

    Current field.

  • $column string

    Current column name.

  • $value string

    Currently entered/selected value for the column’s input.

  • $form_id integer

    ID of current form.

Examples

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' );
}

Placement

This code should be placed in the functions.php file of your active theme

Source Code

This filter is located in GF_Field_List::get_list_input() in includes/fields/class-gf-field-list.php