When i add a new taxonomy term (in page admin/structure/taxonomy/%tid/add) the term gets saved, a status message like "Created new term term-name" is displayed and the same term adding form is rendered without clearing the form data. It may tempt the user to click the save button again result it duplicate terms.

In my opinion it should either redirect the user to term listing page (admin/structure/taxonomy/%tid to show that the term has been added successfully) or clear the input form (in page admin/structure/taxonomy/%tid/add, assuming the user has more terms to add)

D6 assumes the user has more term to add.

CommentFileSizeAuthor
#16 641314_2.patch536 bytesnaxoc
#13 641314_1.patch457 bytesnaxoc
#7 641314.patch673 bytesnaxoc
#2 641314-clear-term-form.patch840 bytesbleen

Comments

bleen’s picture

Title: Redirect the to user to taxonomy term list page or clear the term input form when a new term been added. » Clear the term input form when a new term been added.
Priority: Normal » Critical

I can confirm this issue and it's not good ... I'll see if I cant patch

bleen’s picture

Status: Active » Needs review
StatusFileSize
new840 bytes

I'm not 100% certain this is the correct way to tackle this, but its simple and to the point ... and it seems to work fine.

grndlvl’s picture

Status: Needs review » Needs work

I believe this would break the multistep process maybe if add a check that would see if form is multistep? not sure what correct fix would be for this.

bleen’s picture

@grndlvl ... can you give me a test case? I'm happy to keep going on this, but Im not sure how this might break

sun.core’s picture

Priority: Critical » Normal

Not sure why this was critical.

mr.baileys’s picture

Marked #663988: "Add terms" behavior is confusing as a duplicate of this one. I agree with sun that this is not critical

naxoc’s picture

StatusFileSize
new673 bytes

I couldn't get the patch from #2 to work, but I made a patch that removes some code that does not make sense.

There was a redirect set up to go to admin/structure/taxonomy - I don't think the form should ever redirect to there. With that removed I could remove a rebuild = TRUE and all tests still pass.

naxoc’s picture

Status: Needs work » Needs review
sivaji_ganesh_jojodae’s picture

#7 Works great !!

joachim’s picture

$form_state['rebuild'] is undocumented.

I have applied the patch, and I can confirm it fixes the problem.

However, I HAVE NO IDEA WHY.

This kind of fixing stuff by scrabbling around in the dark is not the way to do it. Hence I am not entirely comfortable marking this as RTBC because I don't understand what the patch does -- all TWO LINES of it.

(See #367006: [meta] Field attach API integration for entity forms is ungrokable for more information on $form['rebuild'] -- or rather for no information at all.)

I get the impression that 'rebuild' is needed for some FieldAPI mojo, so we probably can't just rip it out. However it's clearly messing things up...

catch’s picture

Status: Needs review » Needs work

$form_state['rebuild'] = TRUE means that the form will be re-created if there's an ahah submission - i.e. the 'add more' button for unlimited cardinality fields - so this patch would break that.

Probably, taxonomy_form_term_submit() should set $form_state['rebuild'] = FALSE instead - since if we finally submit the term, we have no need to rebuild the form. I don't have time to write that patch now, but if it works, that ought to not break anything even if it's not 100% the proper fix.

joachim’s picture

In taxonomy_form_term_submit 'rebuild' is FALSE when we get to the comment ' // Massage #text_format.'

naxoc’s picture

Status: Needs work » Needs review
StatusFileSize
new457 bytes

I set a $form_state['rebuild'] = FALSE in the submit handler now and put the $form_state['rebuild'] = TRUE back in the builder.

Was that what you meant? :)

catch’s picture

Title: Clear the term input form when a new term been added. » Taxonomy term form being rebuilt even after final submit

Yes - just removing the redirect, and setting rebuild to FALSE in the final submit. Tested this and it works. Probably needs a comment though, and wouldn't mind an extra review from someone more familiar with this bit of fapi/field AP.

Even though other forms always have redirect set, seems like this ought to be applied in general in case that's removed - we never actually want to rebuild the form after this submit do we?

naxoc’s picture

I put in a comment. I am not sure I understand what you mean by 'applied in general' in the second paragraph?

naxoc’s picture

StatusFileSize
new536 bytes

Oh, and here is the patch

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

By apply in general, I mean we need to apply a consistent pattern to node, comment and user forms too, but that's not for this issue.

joachim’s picture

I would file a followup issue for that, but I'm not really sure how to explain it :/

catch’s picture

I think that comes under the entity / form api ungrokkable issue.

bleen’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
andypost’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

Duplicate of what issue?

bleen’s picture

oooopss .. I misread #20. I thought you were trying to mark *this* issue as duplicate of #722850: On term creation admin/structure/taxonomy/1/add, after submit, fields are still populated with prev term data and thought I was bing helpful. My bad

dries’s picture

Status: Reviewed & tested by the community » Needs review

Well, I still don't understand why we need $form_state['rebuild'] = TRUE to begin with. Clearly, the taxonomy module doesn't need it, and if some module wants to have the form rebuild, they could explicitly set rebuild to TRUE, not? Let's discuss this some more ...

catch’s picture

Status: Needs review » Reviewed & tested by the community

@Dries, it does need it, due to #367006: [meta] Field attach API integration for entity forms is ungrokable - field API cannot function properly without this. This was already pointed out in #10 and #11. Back to RTBC, see you on that issue.

The only difference with taxonomy is that the form doesn't redirect, all the other entity forms do, so you never see the form rebuilt after submit has happened.

catch’s picture

dries’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the clarification. Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

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