Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

add instance question

Avatar

Level 6
Hi,



In my PDf I need to add and remove subform instances dinamically.

I only have/need one subform. This subform has a multi line text field and 2 buttons: add and delete instance. So everytime I create a new instance, I will get a text filed with 2 buttons.



My first requesite was to be able to delete any of the previous created instances. I figured out this using: this.parent.index in the deleted instance.



However, in what regards to creating new instances, I would like also to create each instance, not after all the other previuos created instances, but right after the instance where the button was clicked.



Example:



Initial case:



instance 1



instance 2



instance 3



I need to be able to create a new instance, for example, between instance 1 and instance 3.



instance 1



instance 2 (new)



instance 3



instance 4



Is this possible?



Thank you!
1 Reply

Avatar

Former Community Member
You need to invoke the moveInstance method to move the newly created subform instance from the bottom of the list to under the current instance where the button was clicked.



There is some sample code on page 676 of the Adobe XML Form Object Model Reference.



Regards,



Chris