I'm running AEM Forms 6.3 and experience an issue when dynamically populating a dropdown.
On initialize of a certain field I add an array of items to the dropdown using DropDown.items = array. Now when the filed changes I'd like to replace the items with another set of items. That doesn't work. The new items are appended so the drop down list get's longer. What's strange is that the newly created set of items can be changed but the original assignment is always kept.
Further more printing DropDown.items to the console the correct items show up.
I can reproduce this when a dropdown list is bound.
The error doesn't occur when the dropdown is unbound.
Tested this on 6.2 and it doesn't append the values (which is what I would expect), to me the functionality has changed between 6.2 and 6.3 and I don't know why you would want it to work the way it appears to work in 6.3 so I personally think this is a bug.
A few options:
* if two dropdowns (dropdownA and dropdownB) are bound to the same field, and you set dropdownB.items = ["A=A","B=B","C=C"]; - dropdownB exhibits the appending you have reported *but* dropdownA does not. You could use this to your advantage and hide dropdownB - not pretty, but if you are desperate for a workaround it might help. It will also depend how many dropdowns you have on your form whether this is a viable option.
* Or similarly use an unbound field on the form and copy the value to a bound copy of the field on submit.
* Otherwise, try creating a custom widget for dropdownlist and see if that has the same issue.