Add Multiple Types for List Field Columns [RESOLVED]

Thanks in advance for any help that can be provided. I’ve been able to use the sample code listed here to create a dropdown in one of my columns. How do I add a second one to a second column in the same field? In other words, I have a list field with 4 columns, and I want 2 of them to have drop-downs.

I get a “Cannot redeclare set_column” message using this; I’ve tried some other options but no dice:

add_filter( 'gform_column_input_5_8_2', 'set_column', 10, 5 );
function set_column( $input_info, $field, $column, $value, $form_id ) {
    return array( 'type' => 'select', 'choices' => 'Co-Teacher,Assistant' );
}
add_filter( 'gform_column_input_5_8_3', 'set_column', 10, 5 ); 
function set_column( $input_info, $field, $column, $value, $form_id ) {
    return array( 'type' => 'select', 'choices' => 'Yes,No' );
}

Also, not terribly important, but what do the “10” and “5” designate in this code?

add_filter( ‘gform_column_input_5_8_2’, ‘set_column_two’, 10, 5 );
function set_column_two( $input_info, $field, $column, $value, $form_id ) {
return array( ‘type’ => ‘select’, ‘choices’ => ‘Co-Teacher,Assistant’ );
}
add_filter( ‘gform_column_input_5_8_3’, ‘set_column_three’, 10, 5 );
function set_column_three( $input_info, $field, $column, $value, $form_id ) {
return array( ‘type’ => ‘select’, ‘choices’ => ‘Yes,No’ );
}

This should work. You can’t redeclare a function since there will be conflict.

The 10 represents the priority you’re setting on the filter and the 5 represents how many arguments are being passed to the filter. That, and other info on the add_filter function for WordPress can be found here.

1 Like

Drake

That didn’t work, but it did when I changed “set_column_two” to “set_column2” (and _three to 3).

Thanks!