Advanced Registration Form Reference

On this page

The Admin UI manages Form Fields on Customizations -> Form Fields and forms on Customizations -> Forms . For how advanced registration forms work, see Advanced Registration Forms.

Form Fields and Validation#

FusionAuth validates each step of an advanced registration form when the user submits the step. A validation failure keeps the user on the current step. The theme controls where and how the error messages appear. FusionAuth runs the validation on the server, and some controls add native browser validation. To validate in the browser, add JavaScript to the login templates of the theme. For every check and error code, see User Data Validation.

Form Field Settings#

Id
  • Optional

A UUID for the Form Field. When you leave out the Id, FusionAuth generates one. You can't change the Id after you create the Form Field.

Name
  • Required

The name of the Form Field. The Admin UI shows the name. Users see the label from the theme messages instead.

Field
  • Required
  • Immutable

The key that stores the value. Choose a standard key, such as Email (user.email), or one of the following custom options:

  • Custom user data (user.data.*) stores the value in user.data.
  • Custom registration data (registration.data.*) stores the value in registration.data.
  • Self consent lets the user consent to a Consent during registration.

For a custom option, enter the rest of the key, such as minprice for registration.data.minprice. A key must be unique within the data object.

Consent
  • Optional
  • Immutable

The Consent that the field represents. This field is required when Field is set to Self consent.

Form control
  • Optional
  • Immutable

The HTML control that renders the field. The values are Text, Password, Checkbox, Number, Radio, Select, and Textarea. When a control offers a fixed set of options, such as Radio or Select, the user must choose one of the options.

Data type
  • Optional
  • Immutable

The type that FusionAuth stores the value as. The values are String, Email, Phone, Number, Date, and Boolean. A value that doesn't convert to the data type fails validation. For example, a non-numeric value in a Number field returns an error.

Options
  • Optional

The options of a Checkbox, Radio, or Select control, one per line. Each option must convert to the data type. FusionAuth shows the options in the order you enter them, and translates an option when the theme messages have a key for the option. This field is required for those controls, except on standard fields such as registration.roles, which get options from FusionAuth.

Required
  • Optional
  • Defaults to false

Whether the user must enter a valid value. When Required is off, an empty value is valid.

Confirm value
  • Optional
  • Defaults to false

Whether the user must enter the value twice. FusionAuth adds a second input with the same data type and control, below the first input. The step fails validation when the values differ. You can move the second input in the theme.

Validation
  • Optional
  • Defaults to false

Whether FusionAuth checks the value against Expression.

Expression
  • Optional

A Java regular expression that the value must match. The expression must match the whole value, so [0-9]+ rejects abc123. This field is required when Validation is on.

For the same settings in the API, see the Form Fields API.

Custom Form Fields#

A custom Form Field stores a value under user.data or registration.data. Use user.data for data that several Applications share, and registration.data for data that one Application uses. For more information, see Where FusionAuth Stores the Data.

A theme message with the same key as the field sets the label and placeholder of the field. For more information, see Theme an Advanced Registration Form.

Lambda Validation#

To run more complex checks on a registration, set Self-service registration validation lambda on the Registration tab of the Application. When your plan includes HTTP Lambda Connect, the lambda can call external APIs with fetch. For more information, see Self-Service Registration Validation Lambda.

Form Rules#

A form has a Type of Registration, Admin Registration, Admin User, or Self-service User. Advanced registration forms use Registration. For the admin types, see Custom Admin Forms.

FusionAuth checks the following rules when you save a registration form:

  • The form has at least one step.
  • One step contains an email, phone number, or username field, and the field is required.
  • A field appears only once in the form.
  • A verification step contains no fields.
  • A form has at most one verification step of each type.
  • The user.email field appears before an Email Verification step, and the user.phoneNumber field appears before a Phone Verification step.
  • The password field appears after every verification step.

Each step that collects data needs at least one field.

Consents#

To add a Consent to a form, create a Form Field with Field set to Self consent, and choose the Consent. FusionAuth sets the control from the Consent. A Consent with no values, or with multiple values allowed, renders as a checkbox. A Consent with values that allows only one value renders as radio buttons. For more information, see the Consents API.

FusionAuth names the field after the Consent Id, such as consents['dd35541d-e725-4487-adba-5edbd3680fb8']. To add a label for the Consent, add a line with that name to the theme messages:

consents['dd35541d-e725-4487-adba-5edbd3680fb8']=I consent to sharing my data with affiliated companies

Email Localization#

FusionAuth localizes emails in the preferred languages of the user. When a registration form sets user.preferredLanguages, FusionAuth localizes the first emails, such as the password setup email or the email verification email. For more information, see Localization and Internationalization.

To let the user choose a language, add the standard Preferred languages Form Field to the form:

The form editor with a preferred language field on a registration step.
The form editor with a preferred language field on a registration step.

The default theme renders user.preferredLanguages as a select box with every supported locale, and ignores the Options of the field. To offer fewer locales, change the locale_select macro in the theme Helpers. To set the language without a select box, render the field as a hidden field and set the value with JavaScript. For more information, see Add a Hidden Field.

Manage Forms With the API#

The Form Fields API and the Forms API manage advanced registration forms. Use the APIs to copy form configuration between environments, or to create registration forms for new Applications.

For example, a private-labeled application can let an administrator choose the required registration fields without access to the Admin UI. A custom interface calls the FusionAuth APIs to build the form and associate the form with the Application.

Special Considerations#

Pre-verification#

Available since 1.62.0

An advanced registration form can verify an email address or a phone number before FusionAuth creates the user. For more information, see Email Identity Pre-Verification and Phone Identity Pre-Verification.

Searching on User Data#

When you use the Elasticsearch search engine, FusionAuth indexes all data in registration.data and user.data. Search the values with the User Search API.

The following Elasticsearch query finds the users with a minprice value between 50000 and 100000:

Example JSON for the query parameter to search for users with a given house hunting price range
{
  "bool": {
    "must": [
      {
        "nested": {
          "path": "registrations",
          "query": {
            "range": {
              "registrations.data.minprice": {
                "gte": 50000,
                "lte": 100000
              }
            }
          }
        }
      }
    ]
  }
}

Adding Required Fields Later#

With self-service registration on, FusionAuth checks that the Registration is complete each time a user logs in through the hosted login pages. The check happens after the authorize request and before the redirect.

When you add a required field to the registration form after users register, FusionAuth sends each of those users to the form at the next hosted login. The user fills out the missing field. FusionAuth renders the form with the OAuth complete registration template.

When a user logs in with a single sign-on method, such as Google or SAML, without every required field, FusionAuth also sends the user to the registration form. To skip the form for Identity Provider logins, set every required field in the reconcile lambda of the Identity Provider.

Note

FusionAuth ignores Email Verification and Phone Verification steps when an existing user completes a registration. Gating enforces verification for existing users. For more information, see Gate Users Until They Verify Their Email and Gate Users Until They Verify Their Phone Number.

Modifying an Existing Form Field#

You can't change the Field, Consent, Form control, or Data type of a saved Form Field. You can change the other settings.

To change one of those settings, duplicate the Form Field, change the duplicate, and update the form to use the duplicate. FusionAuth doesn't delete a Form Field that a form still uses. For example, to show the minimum price as a select box instead of a number input, duplicate the minimum price field, change the control, and replace the field in the form.

Caution

When you use Elasticsearch, a new data type for the same key in registration.data or user.data can conflict with the existing index and require manual index updates. When you must change the data type of a Form Field, use a new key.

Registration With Other Identity Providers#

When an Application allows registration with an external Identity Provider, such as Facebook or Active Directory, FusionAuth sends the user into the registration form after the Identity Provider returns.

For example, a form has optional fields in the first step and required fields in the second step. A user registers with Facebook. FusionAuth sends the user to the second step, and the user completes the form from the second step onward.

Self-Service Registration and Registrations#

When an Application has Registration mode set to Create registration, a user without a RegistrationThe association between a User and an Application. for the Application can log in through the hosted login pagesThe login, registration, password recovery, and multi-factor authentication pages that FusionAuth serves. A Theme controls the look of the pages.. FusionAuth creates the Registration during the login and assigns the default roles of the Application.

Self-service registration applies only to the hosted login pages. The following logins don't create a Registration, even when Registration mode is Create registration:

  • A login with the Login API. The Login API returns a 202 status code and no refresh token.
  • A login with the Password GrantAn OAuth 2.0 grant type in which the user gives a username and password directly to the application. RFC 9700 forbids this grant.. FusionAuth returns tokens, but the user stays unregistered. For more information, see Users Without a Registration.

To register a user who logs in with an API, create the Registration from your server with the Registrations API. For more information, see Register a User and Log In.

A login through an Identity ProviderAn external system, such as Google or Microsoft Entra ID, that FusionAuth can use for authentication. can also create a Registration. When Create registration is on for the Application in the Identity Provider, FusionAuth creates the Registration for both hosted and API logins, with any Registration mode. When Create registration is off, only a hosted login to an Application in Create registration mode creates the Registration. For more information, see Applications and Overrides.

For example, a Tenant has the following Applications:

  • Pied Piper Video Chat, with Registration mode set to Create registration
  • Pied Piper Email Service, with self-service registration disabled

The user richard@piedpiper.com has an account in the Tenant, with no Registration for either Application. Richard logs in to Pied Piper Video Chat through the hosted login pages. FusionAuth creates a Registration for Pied Piper Video Chat. The access token contains the applicationId claim and the default roles.

Richard then logs in to Pied Piper Email Service. The login succeeds, because Richard has an account in the Tenant. FusionAuth creates no Registration, so the access token contains no roles and no applicationId claim.

For more information, see Authentication and Authorization.

Admin UI Forms#

Form Fields also build the forms that the Admin UI uses to add and edit users and registrations. For more information, see Custom Admin Forms.