| Versionen | |
|---|---|
| drupal6 | taxonomy_form($vid, $value = 0, $help = NULL, |
| drupal7 | taxonomy_form($vid, $value = 0, $help = NULL) |
Generate a form element for selecting terms from a vocabulary.
see _taxonomy_term_select()
$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.
An array describing a form element to select terms for a vocabulary.
modules/
<?php
function taxonomy_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 -');
}
return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
?>
Kommentare
Kommentar hinzufügen