reason is the specific check for the preview button click in taxonomy_form_alter
When I have my own buttons defined the conversion $node->taxonomy = taxonomy_preview_terms($node); is not done and the form has lost his terms.

How to reproduce? In poll module disable the #ahah button so it becomes a regular button, make sure there is a taxonomy assigned to poll.
Create a poll assign it to a taxonomy field. Edit it and click on 'add choices', when the form reloads the taxonomy is reset to nothing.

enclosed patch fixes the problem but i'm not sure it's the best way to solve it.

Bert

CommentFileSizeAuthor
#8 patch.patch876 bytesbwynants
patch.patch860 bytesbwynants

Comments

catch’s picture

Title: taxonomy menu looses value on button click » Taxonomy selection loses value on button click
Version: 6.x-dev » 7.x-dev
Priority: Critical » Normal
Status: Needs review » Needs work

This will need fixing in D7 first then backporting to 6. Is the bug reproducible just with js disabled?

bwynants’s picture

Assigned: bwynants » Unassigned

I guess so and it is also reproducible by defining your own button without an ahah handler. I have no D7 so then it's up to someone else to fix...

catch’s picture

Version: 7.x-dev » 6.x-dev

Moving back to Drupal 6, there's no taxonomy_form_alter() in D7 any more.

bwynants’s picture

Status: Needs work » Needs review

so patch needs review....

jvandervort’s picture

Status: Needs review » Reviewed & tested by the community

I searched for this, but I guess I didn't look old enough. This is still definitely active.
Marking my issue a duplicate:
#726056: Poll node taxonomy selectbox is reset when you click "more choices"

Until core gets fixed, the workaround in 726056 issue might help some folks.

The patch looks reasonable, but maybe a comment tweak:

  // After a preview or form reload, the terms must be converted to objects.
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Agreed the updated comment would be better. I could have done that myself though :)

What I've noticed by looking around this code is that not too long below the patched lines, isset($form_state['node_preview']) is used again. Is that not affected by the same issue? For me, it looks like it is.

jvandervort’s picture

I don't think the second isset($form_state['node_preview']) requires the same fix.
It uses the already fixed $terms and $node->taxonomy, and it just detecting an actual preview
so it can use the user entered preview terms.

bwynants’s picture

Status: Needs work » Needs review
StatusFileSize
new876 bytes

Nope that isset doesn't need the fix. I'm running with this fix over 15 months with no problems.

fixed comment

jvandervort’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good. It is small, but gets the job done.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Ok, committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.