I have a page that loads the comments section via Ajax once the user scrolls down to the comment section via a custom Drupal ajax callback I defined:
Comments are loaded fine, and using a custom module I'm able to delete, edit, reply and preview comments via Ajax successfully.
The Comment form is loaded via Ajax as well, using this function:
Now, here's the problem.
When the comment form isn't a reply to another comment, if I preview the comment and then save, I get this error:
The form has become outdated. Copy any unsaved work in the form below and then reload this page.
Now, here is the code that's generating the form after it's previewed:
I tried drupal_rebuild_form() instead of drupal_build_form, but I had no success. I searched a lot for a workaround but couldn't find one.
EDIT: It appears that Fivestar is causing the problem. After disabling Fivestar, the form is submitted successfully. However I can't remove fivestar from this page.
Here's what's in $form_state when I click in the preview button: