Hi,
I have the following function to display values from a custom database table in a DDL.
function DDL_Sob($form){
//only populating drop down for form id 27 - Referral
global $wpdb;
if($form["id"] != 27)
return $form;
$sql = "SELECT * FROM <code>bus_source</code> ORDER BY name";
$sobs = $wpdb->get_results($sql, ARRAY_N);
//Creating drop down item array.
$items = array();
$items[] = array("text" => "", "value" => "");
foreach($sobs as $sob)
{$items[] = array("value" => esc_attr($sob->name), "text" => esc_attr($sob->name));}
//Adding items to field id 15. Replace 15 with your actual field id. You can get the field id by looking at the input name in the markup.
foreach($form["fields"] as &$field)
if($field["id"] == 15){
$field["choices"] = $items;
}
return $form;
}
In mySQL the results are generated and in GF/WP the SELECT/OPTION statements are generated for each row but the values/text are empty as in:
<select>
<option value></option>
<option value></option>
<option value></option>
</select>
Any suggestions as to what I've gotten wrong?