Synchronizing repeated content

Availability

This is available since Orbeon Forms 2018.2.

This is an Orbeon Forms PE feature.

Rationale

Often, forms require some kind of master-detail interface, where you first enter a list of initial information, and then complete the information for each item of the list in more details on a separate screen.

A way of doing this with Orbeon Forms consists in:

The difficulty is how to synchronize the two. This is doable with custom XForms code, but it is difficult and error-prone. So Orbeon Forms 2018.2 and newer includes a component which does this synchronization automatically for you.

Configuration

With Orbeon Forms 2018.2, there is no user interface for this yet. You insert the component by editing the source of the form definition with the "Edit Source" toolbox button, and insert a piece of XML in the source.

The synchronization component looks like this:

<fr:synchronize-repeated-content>

It takes the following required XML attributes:

  • left: the name of the source (or "left") repeated grid or repeated section

  • right: the name of the destination (or "right") repeated grid or repeated section

  • sync-on-form-load (optional): [SINCE Orbeon Forms 2023.1] can be set to none to disable right grid synchronization based on left grid on form load; disabling synchronization on load is a way to support having multiple lefts defined to synchronize with a single right, but only one left doing so at any given time, e.g. because the other lefts are irrelevant

  • version: must be 2018.2

Names are as you see them in the Form Builder user interface with the "Grid Settings" or "Section Settings" dialogs.

In addition, it can automatically copy the value of controls from the source to the destination. You specify this with nested <fr:map> elements. They take the following required XML attributes:

  • left: the name of the source (or "left") control

  • right: the name of the destination (or "right") control

Names are as you see them in the Form Builder user interface with the "Control Settings" dialog.

How synchronization works

The synchronization takes place from "left" to "right":

  • Upon form initialization, unless you specified sync-on-form-load="none" (see above), the iterations and values are enforced, which means:

    • Extra iterations in the destination are removed from the end if needed, to match the number of iterations in the source.

    • New iterations in the destination are added at the end if needed, to match the number of iterations in the source.

    • For each iteration, the values of controls specified with <fr:map> are copied over.

  • When iterations are added in the source:

    • Corresponding iterations are added in the destination, at the same position.

  • When iterations are moved in the source:

    • Corresponding iterations are moved in the destination.

  • When iterations are removed in the source:

    • Corresponding iterations are removed in the destination.

  • When values of controls specified by <fr:map> change in the source:

    • The values of the matching controls in the destination are updated.

Full example

The following example does the following:

  • Synchronize repeated iterations between repeated grid master-grid and repeated section detail-section.

  • For each iteration, copy over the value of the traveler-name and traveler-birth-date form controls.

    <!-- other Form Builder code here -->

    <fr:synchronize-repeated-content left="master-grid" right="detail-section" version="2018.2">
        <fr:map left="traveler-name"       right="traveler-name-readonly"/>
        <fr:map left="traveler-birth-date" right="traveler-birth-date-readonly"/>
    </fr:synchronize-repeated-content>
    
    <!-- Put `<fr:synchronize-repeated-content>` just above this. -->
</xf:model>

The following screenshots show how the form looks like when using the wizard view:

Paging large repeated sections

[SINCE Orbeon Forms 2019.1]

When paging of large repeated sections is enabled, optionally with a repetition label, each master repetition appears as its own wizard page. This reduces the size of wizard pages and makes it easier to fill out a form.

See Paging large repeated sections for detail of the configuration.

Limitations

With Orbeon Forms 2018.2, the <fr:synchronize-repeated-content> has the following limitations:

  • The source grid or section must be visible for the synchronization to work. The destination, on the other hand, can be hidden.

  • Both repeated content must be at the top-level: they cannot be nested within other repeated sections.

  • Synchronization within section templates is not supported.

See also

Last updated