Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Adding a set of fields using a button

Avatar

Former Community Member

Hi Paul,

I was looking to add an a group of items (few fields) dynamically by the end user upon clicking add and came accross one of your earlier posts that had exactly what I was looking for. Can you help me unserdstand how to do that? I am attaching your copy for reference of what I am asking for and a sample of mine (in mine, I want to add the whole set of information in insertion #1 and recusrsively add as many as needed by the user). Your help would be much appreciated, thanks!

Vijay

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi,

To be able add set of fields it is better to wrap it in subform as I did in attachment. Also your form has to be  dynamic and flowable.

Main script which adds is

subform.instanceManager.addInstance();

Modifyed form attached.

BR,

Paul Butenko

View solution in original post

4 Replies

Avatar

Correct answer by
Level 6

Hi,

To be able add set of fields it is better to wrap it in subform as I did in attachment. Also your form has to be  dynamic and flowable.

Main script which adds is

subform.instanceManager.addInstance();

Modifyed form attached.

BR,

Paul Butenko

Avatar

Former Community Member

Hi Paul,

This works perfectly as I wanted to, but can you help me understand how you did that? All I could see is that you have added main.insertion.instanceManager.addInstance(); to the "Add button" I did the same to a different form but couldn't make the changes I needed. Can you please give me step by step instructions for the same or point me to where I can find that info? Sorry if I am being a novice and asking very basic questions.

Also, can you help me add a delete button to the added instances so the user can delete if they created one by mistake.

Thanks,

Vijay

Avatar

Level 6

Hi,

1) I made main subform flowed

2) Enabled repeat date fo each item for insertion subform

3) Form prewiev - interactive

  

4) And saved form as dynamic

Avatar

Level 6

To delete instance first you should define index of subform like - this.index.

Then main.isertion.removeInstance(this.index).

Play around it.