OK, this is a subtle bug. To verify:

1. You have to have at least two vocabs (Voc1 and Voc2) with multiple term selection enabled, with "not required" option.
2. Go to a node, select a term (call it Term1) for Voc1, and "none" for Voc2.
3. Save.
4. Go back to edit.
5. *bug* - the "none" option is not highlighted (nothing is selected for Voc2).
6. Do changes to your nodes, save, get error: "Illegal choice for Voc2".

Now, why doesn't the "none" option in vocab get selected? The problem is in _taxonomy_term_select($title, $name, $value, $vocabulary_id ... ) function that gets called for every vocab. However, $value array contains terms for ALL vocabs. In our case, $value has Term1 for Voc1, but the form is creating select options for Voc2. Term1 is not in Voc2, but the logic in the code does not catch such cases.

My patch is very minimal, it does additional check for cases where terms belong to other vocabularies, and sets the default option. In general, the relevant code logic in taxonomy.module is confusing -- I would think that a better solution would be to filter only terms that belong to a specific vocabulary in the calling function before creating a form for that vocabulary.

Darius

CommentFileSizeAuthor
#1 patch_26_0860 bytesdarius
patch_26853 bytesdarius

Comments

darius’s picture

StatusFileSize
new860 bytes

Small fix in the patch.

mfredrickson’s picture

The patch works as advertised. Does not break other vocab types (at least in the combinations I've tried).

I think this is a pretty serious bug and will cause a lot of headaches. Should it be upgraded? I'm lazy and won't bother right now.

I too do not love the solution, but my 10 minutes of trying to solve the problem on the form creation side of the equation yielded nothing.

benc’s picture

I encountered this bug too but with a sligthly different set of conditions. I had two vocabularies, with only one required. On first posting, there was no problem. However, when I edit the posting, that's when the option fails to auto-select and I get an "illegal choice" error.

darius’s picture

Status: Needs review » Fixed

Appears to be fixed in http://drupal.org/node/53351

Anonymous’s picture

Status: Fixed » Closed (fixed)