taxonomy_form, param not used
GreenJelly - February 15, 2008 - 21:58
| Project: | Taxonomy Node Operations |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
$name is not used... I guess this hasn't been used since 4.7! It also needs a better comment.
/**
* Generate a form element for selecting terms from a vocabulary.
*/
function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
$vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $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);
}

#1
/**
* Generate a form element for selecting terms from a vocabulary.
*
* If within the vocabulary database "multi-select" is on it will create a text box else it will develop a drop down value. The code places a single element within the form element that has no $value, this element is '- Please choose -' for multi-select and '- None selected -'
*
* @param $vid
* A vocabulary ID.
* @param $value
* The default value of the form element
* @param $help
* Text that is placed under the form element
* @return
* Form element
*/
function taxonomy_form($vid, $value = 0, $help = NULL) {
$vocabulary = taxonomy_get_vocabulary($vid);
$help = ($help) ? $help : $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), $value, $vid, $help, intval($vocabulary->multiple), $blank);
}
...
removed name as well as whats above...
function _taxonomy_term_select($title, $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,
'#theme' => 'taxonomy_term_select',
);
}
#2
I will make a .patch according to what is needed. If $name is to be removed, then I will patch everything... if $name is to remain, I will .patch with just this description... There is another document change I am working on at... http://drupal.org/node/220226
I will be writing up the finished results on the other document change when I get back on Saturday.
I can contribute both changes... Or maybe just leave them as non-patch files and let the dev-developers pick and choose what they like. The documentation in the first post is new and more comprehensible. I got to run right now... I hope everything clear.
Here is the original...
/*** Generate a form element for selecting terms from a vocabulary.
*/
function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
As Ive been learning these functions I have been writing up this documentation... I have some great examples that can go along with it.
#3
Hi, I read this post...is this helping to get this module working on it's own?
greetings, Martijn