# Create user registration form

You can create a registration form for users to your website by creating a Twig template or editing the existing registration form in YAML file. Follow the instructions below to create and customize templates for a registration form, and a registration confirmation page.

First, make sure you [enabled user registration](https://doc.ibexa.co/en/latest/permissions/permission_use_cases/#register-users).

## Configure existing form

In your configuration, under `allowed_field_definitions_identifiers` [configuration key](https://doc.ibexa.co/en/latest/administration/configuration/configuration/#configuration-files), specify the fields that should be part of your registration form. You can also define what kind of user you want to create under `user_type_identifier`, for example, frontend user. To learn more about available users, see [user types documentation](https://doc.ibexa.co/en/latest/users/user_registration/#user-types).

```
ibexa:
    system:
        default:
            user_registration:
                user_type_identifier: customer
                form:
                    allowed_field_definitions_identifiers:
                        - first_name
                        - last_name
                        - user_account
```

## Add a form template

Add the following configuration under the `ibexa.system.<scope>.user_registration` [configuration key](https://doc.ibexa.co/en/latest/administration/configuration/configuration/#configuration-files):

```
ibexa:
    system:
        default:
            user_registration:
                templates:
                    form: '@ibexadesign/user/registration_form.html.twig'
                    confirmation: '@ibexadesign/user/registration_confirmation.html.twig'
```

This defines which templates are used for rendering the registration form and confirmation page.

In the `templates/themes/<theme_name>/user/registration_form.html.twig` create the template for registration form.

Example registration form:

```
{% extends no_layout is defined and no_layout == true ? view_base_layout : page_layout %}
{% block content %}
    <section class="ibexa-content-edit">
        {{ form_start(form) }}

        {% for fieldForm in form.fieldsData %}
            {% set fieldIdentifier = fieldForm.vars.data.fieldDefinition.identifier %}
            <div class="col-md-6">
                {{ form_widget(fieldForm.value, {
                    'contentData': form.vars.data
                }) }}
            </div>
            {%- do fieldForm.setRendered() -%}
        {% endfor %}

        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                {{ form_widget(form.register, {'attr': {
                    'class': 'btn btn-block btn-primary'
                }}) }}
            </div>
        </div>

        {{ form_end(form) }}
    </section>
{% endblock %}
```

In the `templates/themes/<theme_name>/user/registration_confirmation.html.twig`, create the template for confirmation form.

Example confirmation form:

```
{% extends no_layout is defined and no_layout == true ? view_base_layout : page_layout %}
{% block content %}
    <h1>Your account has been created</h1>
    <p class="user-register-confirmation-message">
        Thank you for registering an account. You can now <a href="{{ path('login') }}">login</a>.
    </p>
{% endblock %}
```

To add a link redirecting to the login form, in the page layout template, provide the following code:

```
<a href="{{ path('ibexa.user.register') }}">Register</a>
```
