#180109 by JirkaRybka: overcome browser quirk to detect when no taxonomy term was selected

6.x
Gábor Hojtsy 2007-11-06 10:01:52 +00:00
parent 5f09149caa
commit e0c7c0e35e
1 changed files with 5 additions and 10 deletions

View File

@ -346,11 +346,10 @@ function taxonomy_del_term($tid) {
function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
$vocabulary = taxonomy_vocabulary_load($vid); $vocabulary = taxonomy_vocabulary_load($vid);
$help = ($help) ? $help : $vocabulary->help; $help = ($help) ? $help : $vocabulary->help;
if ($vocabulary->required) { $blank = 0;
$blank = 0;
} if (!$vocabulary->multiple) {
else { $blank = ($vocabulary->required) ? t('- Please choose -') : t('- None selected -');
$blank = '<'. t('none') .'>';
} }
return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank); return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
@ -895,7 +894,7 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
$options = array(); $options = array();
if ($blank) { if ($blank) {
$options[0] = $blank; $options[''] = $blank;
} }
if ($tree) { if ($tree) {
foreach ($tree as $term) { foreach ($tree as $term) {
@ -905,10 +904,6 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti
$options[] = $choice; $options[] = $choice;
} }
} }
if (!$blank && !$value) {
// required but without a predefined value, so set first as predefined
$value = $tree[0]->tid;
}
} }
return array('#type' => 'select', return array('#type' => 'select',