menu displays <none> twice if vocabulary is not required
therzog - March 6, 2008 - 06:03
| Project: | Primary Term |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
The menu needs to remove [none] when it occurs in the options list, since you add it below. Otherwise you get 2+ [none] choices. Looks like the code was there at some point and got commented out. Here's the patch.
--- primary_term.module 11 Nov 2007 23:02:23 -0000 1.1.1.1
+++ primary_term.module 6 Mar 2008 05:59:44 -0000
@@ -48,9 +48,9 @@
foreach($form['taxonomy'] as $vid => $vocab){
if(in_array($vid, $vids)){
if(is_array($vocab['#options'])){
- if(strlen(trim($vocab['#options']))){
- // not sure why we have the line below. from old days.
- // unset($vocab['#options'][0]);
+ if( !is_object($vocab['#options'][0]) ) {
+ // remove the <none> choice for vocabularies that aren't Required
+ unset($vocab['#options'][0]);
}
$terms = $terms + $vocab['#options'];
}
#1
In drupal 5.4+, the "none" term is keyed with an empty string, not 0. Use this patch instead:
diff -u -r1.2.2.5 primary_term.module
--- primary_term.module 1 Nov 2007 16:39:43 -0000 1.2.2.5
+++ primary_term.module 16 May 2009 22:46:08 -0000
@@ -88,9 +88,9 @@
foreach($form['taxonomy'] as $vid => $vocab){
if(in_array($vid, $vids)){
if(is_array($vocab['#options'])){
- if(strlen(trim($vocab['#options']))){
- // not sure why we have the line below. from old days.
- // unset($vocab['#options'][0]);
+ if( !is_object($vocab['#options']['']) ){
+ // this is the "- None -" choice for optional taxonomies; delete it
+ unset($vocab['#options']['']);
}
$terms = $terms + $vocab['#options'];
}