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.

AEM Forms - Panel Add / Delete control via Form API

Avatar

Level 1

I have been using AEM Form 6 and want to control the addition / deletion of a repetitive panel through form APIs. Can someone help?

3 Replies

Avatar

Level 3

Hi,

I am guessing you are trying to add panels to an Adaptive Form. Correct? If so you can add the following function to your client libabries (I have also included a link to the client library package if you want to install that Dropbox - Forum):

function addPanels(num, repeatablePanel) {

  var iNum = Number(num);

    var im = repeatablePanel.instanceManager;

    var iCurrCount = Number(im.instanceCount);

    while (iNum > iCurrCount) {

       im.addInstance(); // add Instance checks internally for maxCount so you need not do that;

       iCurrCount++;

    }

    while (iNum < iCurrCount) {

       im.removeInstance(iCurrCount- 1); // removeInstance checks internally for minCount

       iCurrCount--;

    }

}

Once you associate the library with the Adaptive Form, you can call the is function from any event and pass in the number of panels you want to display and the name of the panel to repeat.

Gary

Avatar

Level 1

Hi Gary

Thanks for replying.

I would explain what's the thing i want to do.

I have a field in a panel (repetitive). I am using this field in another section to be displayed as a dropdown. Ex - I have a repetive panel with a field 'Name' -  I am displaying all the names (x names if x panels) in a dropdown.

Now my problem is - when i delete any one of the panel, the values in the dropdown (in another section) does not refresh - that means even the panel (and the 'Name' field with its value) are deleted, I am getting those in the dropdown of another section.

So i thought of a solution - that, if on deleting any panel instance, if I can have an eventlistener which will have the logic to refresh those dropdowns with the remaining Panel|Field values. Something like -

window.addEventListener("bridgeInitializeStart", function(evnt){
        guideBridge.on("panelDeleted",function(evt,deletedpanel){
           if(deletedpanel.target.name == 'myRepetitivePanel')
                {

                    refreshDropDown(panel.items[x].applicantName.value); // where the parameter passed will be the name which has to be deleted from the dropdowns

                }

       })
       })

Hope I have made my problem clear. Thanks!

Avatar

Level 3

Hi,

I think it is clear..do you have a sample form, if not I will need to do up one myself.

Gary