When I attempt to add a filter "Taxonomy: Terms for Vocab" where "Vocab" is not required, the first term in the vocabulary is removed from the filter options. This seems to be happening b/c function views_taxonomy_form() unsets $form['#options'][0] if the vocabulary is not required:
file: modules/views_taxonomy.inc
239 else {
240 $form = taxonomy_form($vocabulary->vid, 0, $vocabulary->help);
241 unset($form['#title']);
242 unset($form['#description']);
243 if (!$vocabulary->required) {
244 unset($form['#options'][0]);
245 }
246 unset($form['#default_value']);
247 $form['#multiple'] = TRUE;
248 }
In the taxonomy module of drupal 5.10, function _taxonomy_term_select() (called by taxonomy_form), sets the 'blank' option key to '', not 0:
file: taxonomy.module
1185 if ($blank) {
1186 $options[''] = $blank;
1187 }
So instead of "- None - " being removed from the options in the form, the first valid taxonomy term is unset.
Here's the patch:
Index: views_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/Attic/views_taxonomy.inc,v
retrieving revision 1.27.2.12
diff -u -r1.27.2.12 views_taxonomy.inc
--- views_taxonomy.inc 14 Jul 2007 19:30:51 -0000 1.27.2.12
+++ views_taxonomy.inc 25 Sep 2008 23:45:01 -0000
@@ -241,7 +241,7 @@
unset($form['#title']);
unset($form['#description']);
if (!$vocabulary->required) {
- unset($form['#options'][0]);
+ unset($form['#options']['']);
}
unset($form['#default_value']);
$form['#multiple'] = TRUE;
Comments
Comment #1
csevb10 commentedSame thing as a standalone patch file. I encountered this same issue. This makes it impossible to use views with taxonomy, so I am upgrading the priority of this bug
Comment #2
tanyi commentedIs that the only line that needs to be changed for this issue? This does not fix the issue for me. Thanks.
Comment #3
tanyi commentedComment #4
tanyi commentedIs that the only line that needs to be changed for this issue? This does not fix the issue for me. Thanks.
Comment #5
csevb10 commentedIt should be the only line that gets modified. I believe the views cache needs to be cleared for it to take affect, but that's all. Otherwise, are you certain that you're experiencing the exact same issue?
Comment #6
tanyi commentedI cleared the views cache and it works now. Thanks, you made my day.
Comment #7
esmerel commentedI doubt that this will get committed, but I am marking it 'needs review' in case one of the maintainers gets a chance to look at it before the views 1 is deprecated
Comment #8
esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.