Expand my Community achievements bar.

SOLVED

Unable to add instance of a hidden subform

Avatar

Former Community Member

I am using Adobe Designer 10 and have used the Action functionality to configure my buttons.

Here is the problem:

The user is presented with a question:

     Do you eat apples? Yes/No.

If the user selects the "Yes" checkbox, then the subform , "WhatKindofApples," is set to Visible and appears.

If the user eats more than one kind of apple, then the user should be able to add additional instances of "WhatKindofApples" by clicking the "Add Additional Apples" button.

If the subform, "WhatKindofApples," is set to Visible then the "Add Additional Apples" button works just fine.

If the subform is set to Hidden, then the Add button doesn't work.

So it seems like there is some sort of conflict between being able to add additional instances of hidden subforms once they become visible. I have include the Javascript from my form.

Here is the Javascript for the Add button:

form1.WhatKindofApples.AddAddlApples::click - (JavaScript, client)

//+ GENERATED - DO NOT EDIT (ID:0482B39E-E8D0-4F08-B313-E142D733EE1F CRC:2782582760)

//+ Type: Action

//+ Result1: AddInstance("$Node2")

//+ Node2: form1[0].WhatKindofApples[0]

//+ Node1: form1[0]WhatKindofApples[0].AddAddlApples[0]

//+ Condition1: Button("$Node1","click")

//+ ActionName: AddlEntityPrivate.click

this.resolveNode('form1._WhatKindofApples').addInstance(1);

if (xfa.host.version < 8) {

          xfa.form.recalculate(1);

}

//-

Any help would be greatly appreciated!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I suspect that the addInstance() is attempting to work. Bear in mind that the addInstance() will create a new instance of the repeating object in it's initial state. Therefore if the repeating object is set to hidden, then if new instances are created they will also be hidden.

One work around would be to set the presence of the subform to visible in Design view (Object > Field palette). Then in the Object > Binding palette set the Min count to 0. This means that when the form is rendered, the subform will not be visible. Lastly, the script in the click event of the radio button would add an instance, instead of make it visible.

Hope that helps,

Niall

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi,

I suspect that the addInstance() is attempting to work. Bear in mind that the addInstance() will create a new instance of the repeating object in it's initial state. Therefore if the repeating object is set to hidden, then if new instances are created they will also be hidden.

One work around would be to set the presence of the subform to visible in Design view (Object > Field palette). Then in the Object > Binding palette set the Min count to 0. This means that when the form is rendered, the subform will not be visible. Lastly, the script in the click event of the radio button would add an instance, instead of make it visible.

Hope that helps,

Niall

Avatar

Former Community Member

Dear Niall,

Thanks so much for the response. That fixed it! I had to change the scripting on the radio button first before Designer allowed me to set the Min Count to 0.

Thank you thank you thank you thank you!!!

Avatar

Level 2

Hello,

I have the exact same problem.

I've set the 2 forms to visible, but can't manage to set my min. count to 0, any idea how to do this?

My script on the add buttons is:

rowNum = SECTION3.SF7.parent.index +1;

SECTION3.SF7.instanceManager.insertInstance(rowNum);

xfa.form.recalculate(true)

Thanks in advance!

Nancy

Avatar

Level 1

Hi there,

adding my own solution as using starting 0 instance is not always a way when you have to handle multiple interactivity branches (in your example, if you like apples and have a 3 instances list of apple, changing answer to NO won't hide the whole list!).

I've done much better by wrapping another dummy subform around the one you want to control and making this wrapper invisible, this makes possible to control visibility of the first instance retaining default visibility of the form item to "visible", so it duplicates correctly when asked.

Like this:

Control visibility via the wrapper, control instances directly on Item.

Works,

my thank you to teh community for having me debugging this nasty issue...

L.