You are here

function taxonomy_container_form in Taxonomy container 6

Generate a form element for selecting terms from a vocabulary.

Parameters

$vid: The vocabulary ID to generate a form element for.

$value: The existing value of the term(s) in this vocabulary to use by default.

$help: Optional help text to use for the form element. If specified, this value MUST be properly sanitized and filtered (e.g. with filter_xss_admin() or check_plain() if it is user-supplied) to prevent XSS vulnerabilities. If omitted, the help text stored with the vocaulary (if any) will be used.

Return value

An array describing a form element to select terms for a vocabulary.

See also

_taxonomy_container_term_select()

_taxonomy_term_select()

filter_xss_admin()

1 call to taxonomy_container_form()
taxonomy_container_form_alter in ./taxonomy_container.module
Implements hook_form_alter().

File

./taxonomy_container.module, line 121
Allows users to organize containers using taxonomy terms.

Code

function taxonomy_container_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
  $vocabulary = taxonomy_vocabulary_load($vid);
  $help = $help ? $help : filter_xss_admin($vocabulary->help);
  if (!$vocabulary->multiple) {
    $blank = $vocabulary->required ? t('- Please choose -') : t('- None selected -');
  }
  else {
    $blank = $vocabulary->required ? 0 : t('- None -');
  }
  $vocs = variable_get('taxonomy_container_vids', array());
  $select_func = empty($vocs[$vid]) ? '_taxonomy_term_select' : '_taxonomy_container_term_select';
  return call_user_func($select_func, check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
}