Build an Advanced Registration Form
On this page
In this tutorial, you build a registration form for a fictional real estate application. The first step of the form collects the account details. The second step collects the user's house hunting preferences. You then register a user, view the data in the Admin UI, and read the data with the API.
For how advanced registration forms work, see Advanced Registration Forms.
The form collects the following profile data:
- Password
- First name
- Mobile phone
- The geographic area where the user wants to buy
- The minimum house price
- The maximum house price
Prerequisites#
- A FusionAuth instance with an activated license on a paid plan. To compare plans, see the pricing page. Activation needs outbound network access from FusionAuth. For the activation steps, see Licensing.
- Access to the Admin UI.
Create Form Fields#
FusionAuth ships with Form Fields for standard user data, including the following:
- Phone number
- Username
- Password
- First name
- Middle name
- Last name
- Full name
- Mobile phone
- Birthdate
The first step uses only standard fields. The second step needs custom fields for the house hunting preferences. Only the real estate application uses the preferences, so the custom fields store the values in registration.data. For how to choose between user.data and registration.data, see Where FusionAuth Stores the Data.
After you save a form field, you can't change the Field, Consent, Data type, or Form control settings. To change one of these settings, create a new form field and replace the old field in your forms. Then delete the old field. FusionAuth doesn't delete a form field that a form still uses.
-
In the Admin UI, go to Customizations -> Form Fields . The list shows the standard fields and any custom fields.
-
Click to add a minimum price field. Set Field to
Custom registration data (registration.data.*)and enterminpriceas the key. Set Data type toNumberand Form control toNumber. Turn on Required, so a new user can't finish registration without a value. Save the field.
-
Duplicate the minimum price field to add a maximum price field. Change the name, and set the key to
maxprice. A key must be unique within theregistration.dataobject. Keep the other settings, and save the field. -
Add a geographic area field with the key
geographicarea. Set Data type toString. Leave Required off, because some users don't know yet where they want to buy. Save the field.
The list of form fields now shows the custom fields. Any form can use the fields.
Create a Form#
A form arranges Form Fields into steps. You can put standard and custom fields in any order and add as many steps as you need. Group similar fields in the same step.
Each form needs at least one step and a required email, phone number, or username field. For every rule, see Form Rules.
-
Go to Customizations -> Forms and click . The new form shows a Name field and a button to add steps.

-
Enter a name, and set Type to
Registration. -
Add a step, and add the following fields to the step:
- First name
- Password
- Mobile phone

-
Add a second step, and add the custom fields:
- Geographic area
- Minimum price
- Maximum price

-
To change the order of fields within a step, click the arrows next to a field. To move a field to another step, delete the field from the first step and add the field to the other step.
-
Save the form.
The form controls the steps and the order of fields. To change the validation of a field, edit the field in Customizations -> Form Fields .
Associate a Form With an Application#
An Application uses a form for self-service registration. Any Application in any Tenant can use the same form.
- Go to Applications . Add an Application, or edit an existing Application with .
- On the OAuth tab, add a URL to Authorized redirect URLs. FusionAuth sends the user to the redirect URLThe URL where the authorization server sends the browser after login, with an authorization code or an error. after registration. In most configurations, the user is logged in at the end of registration. Settings such as required email verification change that behavior.
- On the Registration tab, set Registration mode to
Create registration. Without self-service registration, users can't create accounts and never see the form. - Set Type to
Advanced, and set Form to the form you created. - Save the Application.
Register a User#
-
Go to Applications and view the Application with . Copy the Registration URL.

-
Open the registration URL in a private browser window or in another browser. The first step asks for the first name, email address, password, and mobile phone number. Each step shows the number of steps in the form.

-
Fill out the first step and continue. The second step shows the geographic area and the price fields.
-
Fill out the second step and click Register . FusionAuth sends you to the redirect URL and logs you in.
To confirm the registration, log in to the Admin UI and go to Users . Manage the new user, and open the User data tab. The tab shows the custom data:

The theme has no messages for the custom fields yet, so the form shows field keys, such as registration.data.minprice, as labels and placeholders. To add readable labels, placeholders, and error messages, see Theme an Advanced Registration Form.
Read the Data#
FusionAuth returns the profile data from the APIs in the standard user fields, user.data, and registration.data. The Admin UI shows the data on the User data tab. To let admins edit the data in the Admin UI, see Custom Admin Forms.
To let users edit their own profile data, build a profile page in your application. OAuth and OIDC libraries don't return custom data, such as the price range. Read and write the data with the FusionAuth APIs or a client library instead.
The following example is a Python Flask application. The full code, with templates and the login and registration links, is in the example Flask portal on GitHub.
-
Go to Settings -> API Keys and add an API key. Allow the following endpoints:
/api/user/registration: all methods/api/form:GETonly/api/form/field:GETonly
-
Add a home page route that retrieves the Registration of the logged in user:
# ... @app.route('/', methods=["GET"]) def homepage(): user=None registration_data=None fields = {} if session.get('user') != None: user = session['user'] fusionauth_api_client = FusionAuthClient(app.config['API_KEY'], app.config['FA_URL']) user_id = user['sub'] application_id = user['applicationId'] client_response = fusionauth_api_client.retrieve_registration(user_id, application_id) if client_response.was_successful(): registration_data = client_response.success_response['registration'].get('data') fields = get_fields(fusionauth_api_client) else: print(client_response.error_response) return render_template('index.html', user=user, registration_data=registration_data, fields=fields) # ...The route reads the
userobject from the session after a successful login. Thesubclaim holds the user Id, such as8ffee38d-48c3-48c9-b386-9c3c114c7bc9. The route also reads theapplicationIdclaim. The route then retrieves the Registration with the FusionAuth client and passes thedatafield to the template asregistration_data. The route also passes the result of theget_fieldshelper to the template asfields. -
Add the
get_fieldshelper:# ... def get_fields(fusionauth_api_client): fields = {} client_response = fusionauth_api_client.retrieve_form(app.config['FORM_ID']) if client_response.was_successful(): field_ids = client_response.success_response['form']['steps'][1]['fields'] for id in field_ids: client_response = fusionauth_api_client.retrieve_form_field(id) if client_response.was_successful(): field = client_response.success_response['field'] fields[field['key']] = field else: print(client_response.error_response) return fields # ...The helper reads the Ids of the fields on the second step of the form,
['form']['steps'][1]. The helper then retrieves the configuration of each field. The helper stores each configuration in a dictionary under the field key, such asregistration.data.minprice. The update form uses the dictionary to build the inputs. When more than one step collects profile data, change the helper to loop over every step. -
Add a route that processes the update form:
# ... @app.route("/update", methods=["POST"]) def update(): user=None error=None fields=[] fusionauth_api_client = FusionAuthClient(app.config['API_KEY'], app.config['FA_URL']) if session.get('user') != None: user = session['user'] user_id = user['sub'] application_id = user['applicationId'] client_response = fusionauth_api_client.retrieve_registration(user_id, application_id) if client_response.was_successful(): registration_data = client_response.success_response['registration'].get('data') fields = get_fields(fusionauth_api_client) for key in fields.keys(): field = fields[key] form_key = field['key'].replace('registration.data.','') new_value = request.form.get(form_key,'') if field['control'] == 'number': registration_data[form_key] = int(new_value) else: registration_data[form_key] = new_value patch_request = { 'registration' : {'applicationId': application_id, 'data' : registration_data }} client_response = fusionauth_api_client.patch_registration(user_id, patch_request) if client_response.was_successful(): pass else: error = "Unable to save data" return render_template('index.html', user=user, registration_data=registration_data, fields=fields, error=error) return redirect('/') # ...The route retrieves the Registration and copies the new values from the update form into the
dataobject. The route convertsnumbervalues from strings. You can extend the conversion tobooleanor other data types. The route then sends aPATCHrequest, which updates only thedatafield of the Registration.
To confirm the result, log in to the Flask application and change a price. The profile page shows the new value:

Related
Learn how to add labels, placeholders, error messages, and hidden fields to an advanced registration form with a custom theme.
Learn about advanced registration forms, which collect custom profile data over one or more steps during self-service registration.
Reference for advanced registration form fields, validation, form rules, consents, localization, and edge cases such as required fields added later.
Learn about the APIs for creating, retrieving, updating and deleting forms.