Possible error in FormSet#addAnother()
How to reproduce?
- Creating a FormSet object
- FormSet#addAnother() => name="form-0-...."
- FormSet#addAnother() => name="form-0-...." name="form-1-...."
- FormSet#removeForm(0) => basically any index other than the highest name="form-1-....
- FormSet#addAnother() => the sequence number of the newly created field is always equal to FormSet#totalFormCount() name="form-1-...." name="form-1-...."
As a result, the new field either contains the value of the "form-FormSet#totalFormCount()-....", if it was filled in, or behaves weirdly when I start typing.
Please, correct me, if I am wrong, but I believe, that the FormSet#_constructForm() should be called with a unique sequence number, rather then FormSet#totalFormCount(). https://github.com/insin/newforms/blob/react/src/FormSet.js#L596
At the moment I am passing _constructForm a counter, which increases by one every time when addAnother is called.
So by calling FormSet#addAnother() in step 5, I would get => name="form-1-...." name="form-2-...."
All the current test were passed, so I suppose, it should not break anything. It is a minor change, but if you are happy with this solution, I could send a PR. With thanks,