Hi, I have the drop down values in an array (Company A, Company B, Company C, Others). I tried to make use of the gform_pre_render but I'm not really good at it. The result I got was a drop down list with only 1 item ie Company A, Company B, Company C, Others instead of it being 4 items in the list. Please help. (Source code below)
function populate_dropdown($form){
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("asm", $con);
$result = mysql_query("SELECT * FROM <code>wp_cimy_uef_fields</code> WHERE ID = '1'");
$label = mysql_fetch_assoc($result);
$company = array();
$company = $label[LABEL];
$items = array();
$items[] = array("text" => "", "value" => "");
$items[] = array("text" => $company, "value" => $company);
foreach($form["fields"] as &$field)
if($field["id"] == 18){
$field["choices"] = $items;
}
return $form;
Posted 12 years ago on Wednesday September 12, 2012 |
Permalink