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.

repeating subforms

Avatar

Former Community Member

Hello,

I have a form where if the user checks box A, it will open a section with a repeating subform. if the user clicks add, it will add a new instance of the subform. if you then go back and uncheck box A, the repeating subforms should disappear, however they are staying visible.

In the 'change' event of the check box I have the following code:

if(this.rawValue == "1")

{

subfrmRepeatingForm.presence = "visible";

subfrmRepeatingBtn.presence = "visible";

}

if (this.rawValue == "0")

{

subfrmRepeatingForm.presence = "hidden";

subfrmRepeatingBtn.presence = "hidden";

Can anyone offer some help as to why these fields are not clearing?

Thank you in advance,


Nik

7 Replies

Avatar

Level 10

Not sure if it's just the way you copy and pasted the code but you are missing the final brace "}" in the second statement.

Avatar

Former Community Member

ya, i just copied and pasted it wrong. i have the final brace in the code. any idea why this is happening?

Avatar

Level 10

Hard to say, the code looks ok. It could be how your subforms are structured.

Are the repeating subforms all inside the subfrmRepeatingForm subform?

Avatar

Level 10

Hi,

A couple of suggestions.

If you want to use the change event then you would need to swap out "this.rawValue", with "xfa.event.newText".

With checkboxes I tend to use the click event. When this fires, the users selection has been committed and can be accessed from this.rawValue.

Lastly, a checkbox can be on or off (default), therefore a simpler if/else should cover it:

if (this.rawValue == 1) {

     subfrmRepeatingForm.presence = "visible";

     subfrmRepeatingBtn.presence = "visible";

}

else {

     subfrmRepeatingForm.presence = "hidden";

     subfrmRepeatingBtn.presence = "hidden";

}

Hope that helps,

Niall

Avatar

Former Community Member

Thank you for your help Niall.  I have moved this script to the click event as suggested however when i uncheck the check box, all instances of the repeating subform still appear. do i need to enter a specific script to have the repeating subforms hide?

Thank you in advance for your help,

Nik

Avatar

Level 10

Hi Nik,

Sorry for delay.

You are only referencing one instance of the repeating object (eg the first one). One solution would be to loop through all of the instances of the repeating subform and set the presence of each one in turn. Ther are plenty examples on the forum of xfa.resolveNode()/xfa.resolveNodes() on the forums. Also look here: http://assure.ly/kUP02y.

One other solution would be to put the repeating subforms into a parent flowed subform and then just change the presence of this single subform instead. Single object reference and no looping.

Hope that helps,

Niall

Avatar

Former Community Member

Thank you for your help Niall.  I take  alook at the website and examples and see if I can figure it out.

Nik.