Lets assume this is my model instance:
<xforms:instance id="main">
<form>
<section-1/>
<section-2/>
<rep-section>
<a/>
<b/>
<c/>
</rep-section>
</form>
</xforms:instance>
I have a scenario where in i have an repeatable section <rep-section>
which can be dynamically added in the form by an 'Add' button in form. There is another button only on first section 'Copy to other sections' which on click should copy the entire contents in the first section to the rest of the sections. Say if i have 7 sections, then the first section contents should be copied to the remaining 6 sections.
Please advise how we can achieve this.
I have an idea which works fine, but i think there should be an optimized way to do this.
<xforms:trigger appearance="minimal">
<xforms:label>Copy to other Sections</xforms:label>
<xforms:action ev:event="DOMActivate">???</xforms:action>
</xforms:trigger>
The following will do it:
<xforms:trigger>
<xforms:label>Copy to other section</xforms:label>
<xforms:action ev:event="DOMActivate">
<xxforms:variable name="source" select="."/>
<xforms:action ev:event="DOMActivate" xxforms:iterate="../* except .">
<xforms:delete ref="*"/>
<xforms:insert context="." origin="$source/*"/>
</xforms:action>
</xforms:action>
</xforms:trigger>
You can see in action in this full example.