# Singleton form

## Use case

Most forms are filled out for a given purpose, and then submitted. When the initial purpose comes up again, the form is filled and submitted one more time. For instance, a *car registration* form would be such an example. However, certain forms are often used more like "documents", that users create, and then come back to update, without creating another instance of that form/document. Those forms are here referred to as *singleton forms*.

## In Form Builder

As a form author, you can mark a form as *singleton* in Form Builder by opening the *Form Settings* dialog, and clicking on the *Singleton form* checkbox.

![Form Options](https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-1c95210d4c2eb3a357ed65c64056a834edbe90de%2Fform-options.png?alt=media)

## In Form Runner

### New page

When accessing the *new* page of a singleton form, the behavior depends on how many form records the current user can access for that form:

* 0: if the user has no access to any existing records for the form, they remain on the *new* page.
* 1: if the user can access exactly one record, they are redirected to the *edit* page for that form.
* 2 or more: a warning message (shown below) informs the user that no additional records can be created. A button allows them to navigate to the *summary* page, where they can select a record to edit.

\[SINCE Orbeon Forms 2024.1.3] Database checks now prevent a user who already has access to form data from creating additional data, protecting singleton forms against adversarial attempts to create multiple entries. This improvement is available on all supported databases except Oracle.

\[SINCE Orbeon Forms 2026.1, 2025.1.1, 2024.1.5] The above count doesn't take into account any autosaved documents that might exist for the current form. Moreover, if user stays on the *new* page (case 0 above), then [autosave](https://doc.orbeon.com/form-runner/persistence/autosave) is disabled.

![Message when multiple documents are found](https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEkBiSDvlXs3VWiO0Zu%2F-Lt6xPteIeX2_CDBogxS%2F-Lt6xezoN8aR_agv_w9E%2Fsingleton-form-multiple.png?generation=1573165381152442\&alt=media)

### Summary page

When accessing the *summary* page for a singleton form, the *New* button won't show if the user can access 1 or more form data.

### Driven by permissions

The simplest use case, described above, calls for having at most one form data per user. However, since the *singleton* aspect is driven by what users can see, you can use permissions to control whether you want to have one form per user, per group, per users having a given role, or even in the whole system.

This also means that it might still be possible for certain users to see multiple forms, hence the third case above (*two or more* form data). For example, if you set up permissions so regular users can only see their own data, they will be able to create at most one form data, but someone with the `admin` role can view all the data.

## See also

* [Form Settings](https://doc.orbeon.com/form-builder/form-settings)
