{% extends "../layouts/app.html" %}

{% block title %}注册{% endblock %}

{% block content %}
<div class="container">
  <div class="row justify-content-center">
    <div class="col-md-8">
      <div class="card">
        <div class="card-header">注册</div>

        <div class="card-body">
          <form method="POST" action="{% route 'register' %}">
            {{ csrfInput | safe }}

            <div class="form-group row">
              <label for="name" class="col-md-4 col-form-label text-md-right">姓名</label>

              <div class="col-md-6">
                <input id="name" type="text" class="form-control {% if validatorMessageMap.name %} is-invalid {% endif %}"
                  name="name" value="{{ oldValue.name }}" required autofocus>

                  {% if validatorMessageMap.name %}
                    <span class="invalid-feedback" role="alert">
                      <strong>{{ validatorMessageMap.name.0 }}</strong>
                    </span>
                  {% endif %}
              </div>
            </div>

            <div class="form-group row">
              <label for="email" class="col-md-4 col-form-label text-md-right">E-mail</label>

              <div class="col-md-6">
                <input id="email" type="email" class="form-control {% if validatorMessageMap.email %} is-invalid {% endif %}"
                  name="email" value="{{ oldValue.email }}" required>

                {% if validatorMessageMap.email %}
                  <span class="invalid-feedback" role="alert">
                    <strong>{{ validatorMessageMap.email.0 }}</strong>
                  </span>
                {% endif %}
              </div>
            </div>

            <div class="form-group row">
              <label for="password" class="col-md-4 col-form-label text-md-right">密码</label>

              <div class="col-md-6">
                <input id="password" type="password" class="form-control {% if validatorMessageMap.password %} is-invalid {% endif %}"
                  name="password" required>

                {% if validatorMessageMap.password %}
                  <span class="invalid-feedback" role="alert">
                    <strong>{{ validatorMessageMap.password.0 }}</strong>
                  </span>
                {% endif %}
              </div>
            </div>

            <div class="form-group row">
              <label for="password-confirm" class="col-md-4 col-form-label text-md-right">确认密码</label>

              <div class="col-md-6">
                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
              </div>
            </div>

            <div class="form-group row">
              <label for="captcha" class="col-md-4 col-form-label text-md-right">验证码</label>

              <div class="col-md-6">
                <input id="captcha" class="form-control {% if validatorMessageMap.captcha %} is-invalid {% endif %}"
                  name="captcha" required>
                <input type="hidden" name="captcha_id" value="{{ captcha.ID }}">

                <img class="thumbnail captcha mt-3 mb-2" src="{{ captcha.ImageURL }}" onclick="this.src='{{ captcha.ImageURL }}?reload='+Math.random()" title="点击图片重新获取验证码">
                <!--音频验证码
                <audio src="{{ captcha.AudioURL }}?lang=zh" controls="controls">
                  Your browser does not support the audio tag.
                </audio>-->
                {% if validatorMessageMap.captcha %}
                  <span class="invalid-feedback" role="alert">
                    <strong>{{ validatorMessageMap.captcha.0 }}</strong>
                  </span>
                {% endif %}
              </div>
            </div>

            <div class="form-group row mb-0">
              <div class="col-md-6 offset-md-4">
                <button type="submit" class="btn btn-primary">
                  注册
                </button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}

