You are here

function merci_taxonomy_term_select in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2

1 call to merci_taxonomy_term_select()
merci_form_alter in ./merci.module
Implementation of hook_form_alter().

File

./merci.module, line 431
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function merci_taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
  $tree = taxonomy_get_tree($vocabulary_id);
  $options = array();
  if ($blank) {
    $options[''] = $blank;
  }
  if ($tree) {
    foreach ($tree as $term) {
      if (!in_array($term->tid, $exclude)) {
        $choice = new stdClass();
        $choice->option = array(
          $term->tid => str_repeat('-', $term->depth) . $term->name,
        );
        $options[] = $choice;
      }
    }
  }
  return array(
    '#type' => 'select',
    '#title' => $title,
    '#default_value' => $value,
    '#options' => $options,
    '#description' => $description,
    '#multiple' => $multiple,
    '#size' => $multiple ? min(9, count($options)) : 0,
    '#weight' => -15,
  );
}