Skip to content

Instantly share code, notes, and snippets.

@avernet
Created January 26, 2012 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avernet/1685914 to your computer and use it in GitHub Desktop.
Save avernet/1685914 to your computer and use it in GitHub Desktop.
Copy a section to all the other sections in XForms
<xhtml:html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xhtml:head>
<xforms:model>
<xforms:instance>
<instance>
<rep-section>
<first-name/>
<last-name/>
</rep-section>
<rep-section>
<first-name/>
<last-name/>
</rep-section>
<rep-section>
<first-name/>
<last-name/>
</rep-section>
</instance>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<xforms:repeat ref="rep-section">
<xhtml:div>
<xforms:input ref="first-name">
<xforms:label>First name: </xforms:label>
</xforms:input>
<xforms:input ref="last-name">
<xforms:label>Last name: </xforms:label>
</xforms:input>
<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>
</xhtml:div>
</xforms:repeat>
</xhtml:body>
</xhtml:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment