1

I am trying to save comments using the core method "entries/saveEntry", but every time I submit the form the last comment is overwritten, is there a simple way of submitting this information to insert instead of update all the comments?

I the form working in that it relates a comment to an entry using the following form:

<form method="post" accept-charset="UTF-8">
    <input type="hidden" name="action" value="entries/saveEntry">
    {{ getCsrfInput() }}
    <input type="hidden" name="entryId" value="{{ entry.id }}">
    <input type="hidden" name="fields[usercomments][new1][type]" value="comments">
    <input type="text" name="fields[usercomments][new1][fields][commentuser]" value="">
    <input type="text" name="fields[usercomments][new1][fields][commenttext]" value="">
    <input type="submit" value="Publish">
</form>

I just dont get why the comments are being overwritten and how to just insert a new entry.

ConquestXD
  • 287
  • 2
  • 6

2 Answers2

1

You'll have to resubmit all the previous comments through hidden fields aswell. You can achieve this by looping through them in the form, and put their values into hidden inputs.

Bob Olde Hampsink
  • 1,173
  • 7
  • 27
1

As @carlcs mentioned, it's likely due to the way you're saving the ID...

<input type="hidden" name="entryId" value="{{ entry.id }}">

I would omit this line to ensure you save a new comment each time.

If you actually want to have a form that allows editing of existing comments, then you need to pass in the ID of the comment, not the ID of the parent entry.

Simon East
  • 890
  • 6
  • 21