Friday 7 December 2012

get vocabulary list dropdown programmatically

/**
 * programmatically show taxonomy dropdown
 */
$taxonomy_source = taxonomy_get_tree(2);
$options_arr = array('0' => '--none--');
foreach($taxonomy_source as $taxonomy_items) {
    $tid = $taxonomy_items->tid;
    $t_name = $item->name;
    $options_arr[$tid] = $t_name;
}

/**
 * Category Dropdown
 */
$form['filterset']['category'] = array(
  '#weight' => '1',
  '#key_type' => 'associative',
  '#multiple_toggle' => '1',
  '#type' => 'select',
  '#options' => $options_arr,
  '#title' => 'Categories',
);

unset($options_arr);

No comments:

Post a Comment