Expand my Community achievements bar.

Instantiate choice subsets on run-time

Avatar

Level 1

Hello everyone.

I have an XSD like the following:

<xs:sequence maxOccurs="unbounded">
 
<xs:choice>
   
<xs:element name="Item1" type="xs:string" />
   
<xs:element name="Item2" type="xs:string"/>
 
</xs:choice>
</xs:sequence>

and I want to use a choice subset to represent this. For now I have something like the following:

MyForm (Subform)
 
ItemsSubForm (Subform, repeated for many items)

    ItemChoice (ChoiceSubset)
     
Item1Wrapper (Subform)
       
Item1 (TextField)
     
Item2Wrapper (Subform)
       
Item2 (TextField)
 
AddItemsButtonsSubForm
   
AddItem1Button (Button)
   
AddItem2Button (Button)

Everything is working fine, but I also want to give the opportunity to the user to manually create his own items. So, by pressing AddItem1Button, I want to create a new Item1Wrapper, and similarly with Item2Wrapper and AddItem2Button.

Now I have the following javascript line for AddItem1Button:

this.parent.parent._ItemsSubForm.addInstance();

which creates a new ItemsSubForm, but how can I create a new Item1Wrapper? In other words, how can I instantiate a child of a choice subset in run-time?

Thank you.

0 Replies