I have this function in like, 6 of my modules. I've seen it in dozens of contributed modules. Every time a developer wishes to present the user with a checkbox or select list of vocabularies, they have to write this function. I think it would make for a good inclusion in Drupal core.

/**
 * Return vocabularies in a format that can be used with FAPI
 *
 * @return array A keyed array of vocabularies
 */
function taxonomy_get_vocabularies_fapi() {
  $vocabs = taxonomy_get_vocabularies();
  
  $options = array();
  foreach ($vocabs as $vocab) {
    $options[$vocab->vid] = $vocab->name;
  }
  
  return $options;
}

Comments

thedavidmeister’s picture

Status: Needs review » Closed (won't fix)

This function is not in core in D8+ and we aren't changing the API in D7-

Please don't set an issue to "needs review" unless it has at least one tested patch posted to the thread.