Hi Carl,
I tried doing this, but it only works on the live form.
For some reason I can't see the choices on the admin page (I still see "First Option, Second Option, Third Option")
Any idea what I'm doing wrong?
Here is my code hook:
add_filter("gform_pre_render", "populate_dropdown");
add_filter("gform_admin_pre_render", "populate_dropdown");
function populate_dropdown($form) {
$vectors = array();
$vectors[0] = array("value" => "pJ201", "text" => "pJ201");
$vectors[1] = array("value" => "pJ204", "text" => "pJ204");
$vectors[2] = array("value" => "pJ206", "text" => "pJ206");
$vectors[3] = array("value" => "pJ241", "text" => "pJ241");
$vectors[4] = array("value" => "pJ244", "text" => "pJ244");
$vectors[5] = array("value" => "pJ246", "text" => "pJ246");
foreach($form["fields"] as &$field) {
if($field["adminLabel"] == "Vector"){
$field["choices"] = $vectors;
}
}
return $form;
}
Posted 13 years ago on Monday May 23, 2011 |
Permalink