{% extends 'flask_user/_public_base.html' %}

{% block title %}
    Register
{% endblock %}

{% block content %}
{% from "flask_user/_macros.html" import render_field, render_submit_field %}
<h1>{%trans%}Register{%endtrans%}</h1>

<form action="" method="POST" novalidate formnovalidate class="form" role="form">
    {{ form.hidden_tag() }}
    {# Username or Email #}
    {% set field = form.username if user_manager.USER_ENABLE_USERNAME else form.email %}
    <div class="form-group {% if field.errors %}has-error{% endif %}">
        {# Label on left, "Already registered? Sign in." on right #}
        <div class="row">
            <div class="col ml-1">
                <label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
            </div>
            <div class="col-xs-6 text-right">
                {% if user_manager.USER_ENABLE_REGISTER %}
                    <a href="{{ url_for('user.login') }}" tabindex='290'>
                        {%trans%}Already registered? Sign in.{%endtrans%}</a>
                {% endif %}
            </div>
        </div>
        {{ field(class_='form-control', tabindex=210) }}
        {% if field.errors %}
            {% for e in field.errors %}
                <p class="help-block text-danger">{{ e }}</p>
            {% endfor %}
        {% endif %}
    </div>

    {% if user_manager.USER_ENABLE_EMAIL and user_manager.USER_ENABLE_USERNAME %}
        {{ render_field(form.email, tabindex=220) }}
    {% endif %}

    {% if config.REQUIRE_PLAY_KEY %}
        {{ render_field(form.play_key_id, tabindex=225) }}
    {% endif %}

    {{ render_field(form.password, tabindex=230) }}

    {% if user_manager.USER_REQUIRE_RETYPE_PASSWORD %}
        {{ render_field(form.retype_password, tabindex=240) }}
    {% endif %}

    {{ render_submit_field(form.submit, tabindex=280) }}
</form>

{% endblock %}
