Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Gravity Forms + custom dropdown in a list field WordPress

  • SOLVED

I have a form (id 6) that I have already created a custom dropdown list using the Bulk Add / Predefined Choices called "Sections" and used that list in field id 10 to get the information I require.

Using the Sticky List plugin to allow users to edit the submitted form I then want to have a list field to allow more than one entry of data by other form users. This is where I need help, I have created the list and created the 3 columns (From, To and Requirement/tasking) and used the following code to make the from field a dropdown (found it in the Gravity Forms Forums) but it only allows me to hard code the choices, what I want is to be able to utilise the list I have already created called Section and use it to populate a dropdown for both the To and From fields. This will allow me to redirect the form to the right departments.

// This targets the form number 6 field id 31 column 1 and makes it a dropdown menu
add_filter("gform_column_input_6_31_1", "set_column", 10, 5);
function set_column($input_info, $field, $column, $value, $form_id){
return array("type" => "select", "choices" => "First Choice,Second Choice");
}


Is there anyway to change this code to allow me to use the list I created without having to hard code the information in the functions.php ? If so can anyone help ?

Answers (3)

2016-01-13

Reigel Gallarde answers:

I'm guessing you want a select field on form ID 6, be populated by a select field from form ID 10, right? if that's so, try this..

// This targets the form number 6 field id 31 column 1 and makes it a dropdown menu

add_filter("gform_column_input_6_31_1", "set_column", 10, 5);

function set_column($input_info, $field, $column, $value, $form_id){


$form = GFFormsModel::get_form_meta(10); // form ID 10
$field = GFFormsModel::get_field($form, 3); // 3 here is a field ID, change it to match yours...

$choices = array();
foreach($field['choices'] as $choice) {
$choices[] = $choice['text'];
}

return array("type" => "select", "choices" => implode(",",$choices));

}


or maybe this will too work:

// This targets the form number 6 field id 31 column 1 and makes it a dropdown menu

add_filter("gform_column_input_6_31_1", "set_column", 10, 5);

function set_column($input_info, $field, $column, $value, $form_id){


$form = GFFormsModel::get_form_meta(10); // form ID 10
$field = GFFormsModel::get_field($form, 3); // 3 here is a field ID, change it to match yours...

return array("type" => "select", "choices" => $field['choices'] );

}


Kennyboy7 comments:

Many thanks guys for the effort and speed of replies but alas none of those are working, I just get a blank outline no dropdown. Please see attached images for what I'm trying to achieve.