Wednesday, April 11, 2012

Support for repeats lands in Form Builder

XForms has a rather powerful feature called repeats, which allows form authors to easily create forms with sets of fields that can occur multiple times. Repeats have always been supported by the XForms engine in Orbeon Forms, and now, they can also be used directly from Form Builder.

For instance, consider the "DMV 14" form, from the Department of Motor Vehicles in California, which allows you to list multiple vehicles. In the paper version of the DMV 14, the fields for a vehicle have been repeated 3 times, allowing a maximum of 3 vehicles to be entered. This is how things were on paper, and often today still with PDF, but with web forms, we can do much better: we can enable end users to add or remove vehicles, without even having to impose a limit on the number of vehicles users can enter. And of course, what works for vehicles, works for any set of fields you'd like to see repeated.

Imagine you want to create a conference registration form allowing an organization to suggest talks their members can give. For each talk, you'd like to know the presenter, the topic, and the date/time. In Form Builder, you create a repeat, by clicking on New Repeat on the side bar, (see screenshot to the right). You then create columns and add fields, as you normally would in grids. The following screenshot shows how this looks like in Form Builder.

When filling out the form, users add new lines as necessary clicking on the + sign.

Note how the label for the fields, instead of being repeated on each line, show just once in the table header. Such a table layout works well when you have a few fields repeated. But as the number of fields grows, you'll want to put them on multiple lines, and it will then be a block of lines that gets repeated. This is what we did in the following example, creating a total of 6 fields to be repeated:

Now note how, both in Form Builder (above) and when users fill out the form (below), the labels for the fields show above each fields, as having them just once in the table header wouldn't work anymore. And all this is automatically handled for you.

Repeats in Form Builder will be part of the next release of Orbeon Forms, and if you feel adventurous, you can try them today by downloading a nightly build.

1 comment: