Hello,
I created a new taxonomy vocabulary called Test. This vocabulary is associated with Blog Entry and has single hierarchy. The terms in Test vocabulary are:
Root1
- Sub1 (parent is Root1)
- Sub2 (parent is Root1)
Root2
- Sub3 (parent is Root2)
Root3
After I enabled this taxonomy Test filter with Views CMS tool (exposed filter with optional, single select), the select box overwrote Root1 with '- None selected -'.
When I traced the code, it looks like $option[''] in function _taxonomy_term_select() in taxonomy.module is causing the problem. Changing it to $option[] solves the problem; however, I would like to share the finding with the community and may be there is something more to it. My solution could be wrong. Our PHP version is 5.2.5
- None selected -
- Sub1
- Sub2
Root2
-Sub3
Root3
Thanks,
Kathy
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 321859.patch | 410 bytes | douggreen |
Comments
Comment #1
kathylin commentedI did more investigation. It looks the bug is a result of Taxonomy.module and views_taxonomy.inc.
I reverted the change in taxonomy.module and did the following change in views_taxonomy.inc
function views_taxonomy_form(&$vocabulary) {
if ($vocabulary->tags) {
.......
}
else {
.......
if (!$vocabulary->required) {
unset($form['#options']['']); //change from $form['#options'][0] to $form['#options']['']
}
....
}
return $form;
}
Comment #2
therzog commentedI got the same problem. It's because starting with drupal 5.4, the "blank" option is keyed with an empty string, not the zero-eth element, so views_taxonomy_form() ends up deleting the 1st actual term instead of the "blank" element. Here is my patch: you don't need to do anything to taxonomy.module:
Comment #3
tanyi commentedI tried the above patch but it doesn't work.
Comment #4
levelos commentedThat patch isn't quite right as the unset needs to be inside the conditional. This should do it. Also note you need to edit/save your view for it to be applied.
Comment #5
douggreen commentedI'm really surprised to discover that this is still a problem in views1, but I think that this is correct.
As this works now (and the way I think it's always worked) is that the exposed taxonomy filter shows:
After the patch, the exposed taxonomy filter shows:
I never understood why the "" and "- None -" were both there and formatted differently. It now makes sense. The "" comes from views. And the "- None -" comes from taxonomy, and views intended to remove it.
As far as I can tell the intention of this code was to remove the "- None -" option on vocabulary that isn't required. Required vocabularies are shown on every single node. So, I'm not quite sure what the logic behind this was. I'd think that the "- None -" should always be removed.
I've converted the above to a patch and changed the status of this, so that someone from the views development team might look at it and weigh in. But I don't know if there will ever be another views1release...
Comment #6
douggreen commentedThis is a duplicate of #142347: Not all taxonomy terms showing up in exposed filter and appears to already be fixed in the dev release.