General scenario: I'm using a hook_form_alter to (1) add a custom submit function and (2) to pre-fill some checkboxes with values already saved to the db. The form is used to create content.
Without my form_alter, the form behaves normally. With my form_alter, the form submits properly (writes to the database), but upon page refresh, I don't see the created content. Instead, I see a drupal message telling me it was created, and I see my form with the values still in their fields. If I then visit the 'view' URL for this content, I see it published normally, but I can't get the original submit process to actually refresh the page properly.
More details, if you're still reading: My hook_form_alter is for a NodeComment comment form (which is, therefore, a node form). I'm trying to add a submit function so that taxonomy terms on the nodecomment are saved both to the normal tables and to a custom table. I then use that custom table to pre-fill the taxonomy terms if the user posts a comment on the site again (don't ask why, it just has to be organized this way).
So when I try to "Save" my comment, it does save and sets the right drupal message, but when the page refreshes, the comment isn't rendered and my comment values are still in the comment form below. If I then revisit the node I just commented on, my nodecomment renders.
Weird thing, is that when a user is commenting for the first time, the whole process works. It only breaks down if I add in my "well, you've been here before" code. This constitutes: (1) pre-checking some Taxonomy Super Select checkboxes for the taxonomy terms on the nodecomment, (2) collapsing the fieldset for those taxonomy terms, and (3) saving some custom values in $form_state. Other than that and the UPDATE sql I write instead of the INSERT, nothing is different.
If you've read this far, thanks for enduring. I feel like I'm forgetting something very basic. Any help appreciated!
Comments
The basic thing you are
The basic thing you are forgetting is to show us your code!
Contact me to contract me for D7 -> D10/11 migrations.