Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Action "remove field" always removes first instance


Level 1

I hope I'm explaining this clearly.

I have a section that includes a text box, a few drop down boxes and 4 buttons. This entire section is repeated when one of those four buttons "add" is selected. The forms drops down to make room for the new section.

You can do this as many times as needed. And each new section has the same 4 buttons. Two relevant ones are "add" and "remove" the section.

The issue I'm having is that when you select the "remove" button in ANY of the new (or original) sections, it only removes the original section (or first one if you keep selecting it). The action for that button is set to remove "current instance". If I change to the other options "first instance" "last instance" or instance #, it completes that correctly. But "current instance" always removes the first instance.

I'm thinking the issue might be in how the "add" section includes the buttons themselves.

Any thoughts on what I could do differently or what the issue might be?

1 Reply


Level 7

In case you still need an answer....I would have the add button outside the repeated subform

My subform is called sf

btnAdd: click (javascript)


if (xfa.host.version < 8) {



btnRemove: click (Javascript)


if (xfa.host.version < 8) {



This remove button should remove the subform where the button is clicked. I have had a problem like described as well. This code works for me, but have found when i have had problems i changed this.parent.index to this.sf.index and it worked as desired.