Blog Single Page

Gravity Form Populating Term ID instead of term name

By on 25 March 2014

Gravity Form Populating Term ID instead of term name

###### START GRAVITY FORMS SELECT PRODUCER ######
/*
add_filter("gform_pre_render", "populate_producers_dropdown");

//Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.
add_filter(“gform_admin_pre_render”, “populate_producers_dropdown”);

function populate_producers_dropdown($form){

//only populating drop down for form id 3
if($form[“id”] != 16)
return $form;

//Reading posts for custom post type “place” with custom taxonomy “placecategory” and term “producer”;

$terms = wp_get_post_terms(‘practice_areas’);

// echo ”

";
// print_r($term);
// echo "

“;
//Creating drop down item array.
$items = array();

//Adding initial blank value.
$items[] = array(“text” => “”, “value” => “”);

//Adding post titles to the items array
foreach($terms as $term)
$items[] = array(“value” => $term->ID, “text” => $term->name);

//Adding items to field id 9. Replace 9 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”] == 0){
$field[“choices”] = $items;
}

return $form;
}

###### END GRAVITY FORMS SELECT PRODUCER ######

*/

0 Replies to “Gravity Form Populating Term ID instead of term name”

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 8 =