{#
    Copyright (C) 2007-2018 The LimeSurvey Project Team / Louis Gac / Denis Chenu

    (¯`·._.·(¯`·._.· Registration form._.·´¯)·._.·´¯)

    This is the registration form for participant registration on a survey.

#}

<div class="{{ aSurveyInfo.class.registerform }} row" {{ aSurveyInfo.attr.registerform }}>
    {{ C.Html.form(aSurveyInfo.sRegisterFormUrl,'post',({'id' : 'limesurvey', 'role' : 'form', 'class' : 'form'})) }}

    {{aSurveyInfo.registerform.hiddeninputs}}

    <div class='{{ aSurveyInfo.class.registerformcol }} col-md-8 col-md-offset-2' {{ aSurveyInfo.attr.registerformcol }}>
        <div class="ls-js-hidden form-group row">
            {{ include('./subviews/navigation/language_changer.twig') }}
        </div>
        {# Participants first name #}
        <div class='{{ aSurveyInfo.class.registerformcolrow }} form-group row' {{ aSurveyInfo.attr.registerformcolrow }}>
            <label for='register_firstname' class='{{ aSurveyInfo.class.registerformcolrowlabel }} control-label '>{{ gT("First name:") }}</label>
            <div class="">
                {{ C.Html.textField('register_firstname', aSurveyInfo.sFirstName, ({'id' : 'register_firstname','class' : 'form-control'})) }}
            </div>
        </div>

        {# Participants last name #}
        <div class='{{ aSurveyInfo.class.registerformcolrowb }} form-group row' {{ aSurveyInfo.attr.registerformcolrowb }}>
            <label {{ aSurveyInfo.attr.registerformcolrowblabel }}  class='{{ aSurveyInfo.class.registerformcolrowblabel }} control-label '>{{ gT("Last name:") }}</label>
            <div {{ aSurveyInfo.attr.registerformcolrowbdiv }} >
                {{ C.Html.textField('register_lastname', aSurveyInfo.sLastName, ({'id' : 'register_lastname', 'class' : 'form-control'})) }}
            </div>
        </div>

        {# Participants email #}
        <div class='{{ aSurveyInfo.class.registerformcolrowc }} form-group row' {{ aSurveyInfo.attr.registerformcolrowc }}>
            <label {{ aSurveyInfo.attr.registerformcolrowclabel }} class='{{ aSurveyInfo.class.registerformcolrowclabel }}  control-label'> {{ gT("Email address:") }} {{ include('./subviews/registration/required.twig') }}</label>
            <div {{ aSurveyInfo.attr.registerformcolrowcdiv }}  >
                {{ C.Html.textField('register_email', aSurveyInfo.sEmail, ({'id' : 'register_email','class' : 'form-control','required' : true})) }}
            </div>
        </div>

        {# Loop to add extra attributes #}
        {% for key, aExtraAttribute in aSurveyInfo.aExtraAttributes  %}
            <div class=' {{ aSurveyInfo.class.registerformextras }} form-group row' {{ aSurveyInfo.attr.registerformextras }} >
                {% set registerKey = "register_" ~ key %}
                <label for="{{ registerKey }}" class='{{ aSurveyInfo.class.registerformextraslabel }} control-label '> {{ aExtraAttribute.caption }} {% if aExtraAttribute.mandatory == 'Y' %}{{ include('./subviews/registration/required.twig') }}{% endif %}</label>
                <div {{ aSurveyInfo.attr.registerformcolrowcdiv }} >
                    {{ C.Html.textField(registerKey, aSurveyInfo.aAttribute[key],({'id' : "register_{$key}",'class' : 'form-control input-sm'})) }}
                </div>
            </div>
        {% endfor %}

        {# Captcha box #}
        {% if aSurveyInfo.bCaptcha %}
            <div class='{{ aSurveyInfo.class.registerformcaptcha }} form-group row ' {{ aSurveyInfo.attr.registerformcaptcha }}>
                <label class='{{ aSurveyInfo.class.registerformcaptchalabel }} control-label ' {{ aSurveyInfo.attr.registerformcaptchalabel }} >{{ gT("Please solve the following equation:") }} {{ include('./subviews/registration/required.twig') }}</label>
                <div {{ aSurveyInfo.attr.registerformcaptchadiv }}>
                    <div class='{{ aSurveyInfo.class.registerformcaptchadivb }} input-group' {{ aSurveyInfo.attr.registerformcaptchadivb }}>
                        <div class='{{ aSurveyInfo.class.registerformcaptchadivc }} control-label' {{ aSurveyInfo.attr.registerformcaptchadivc }}>
                            {{ renderCaptcha().renderOut() }}
                            <!-- TODO: Problems with reload and name getting empty/not in POST. -->
                            <a href="#" class="btn btn-sm btn-default" onclick="window.location.reload();" id="reloadCaptcha" title="{{ gT("Reload captcha") }}" data-toggle="captcha"><i class="fa fa-refresh"></i></a>
                        </div>
                        <input class='{{ aSurveyInfo.class.registerformcaptchainput }} form-control' {{ aSurveyInfo.attr.registerformcaptchainput }} >
                    </div>
                </div>
            </div>
        {% endif %}

        {# Mandatory information #}
        <div class='{{ aSurveyInfo.class.registermandatoryinfo }} row' {{ aSurveyInfo.attr.registermandatoryinfo }} >
                {{ gT('Fields marked with an asterisk are mandatory.')}}
        </div>

        {# Submit register button #}
        <div class='{{ aSurveyInfo.class.registersave }} form-group row' {{ aSurveyInfo.attr.registersave }} >
            <div class='{{ aSurveyInfo.class.registersavediv }} col-md-offset-7' {{ aSurveyInfo.attr.registersavediv }} >
                {% set continue = gT("Continue",'unescaped') %}
                <button {{ aSurveyInfo.attr.registersavedivbutton }}  class='{{ aSurveyInfo.class.registersavedivbutton }} btn btn-default' >
                    {{ continue }}
                </button>
            </div>
        </div>

        {# If there is additional form parts, a.e. trhough a plugin render it out here #}
    </div>
    <div class='{{ aSurveyInfo.class.registerformcoladdidtions }} col-md-8 col-md-offset-2' {{ aSurveyInfo.attr.registerformcoladdidtions }}>
        {{ aSurveyInfo.formAdditions | raw  }}
    </div>

    {{ C.Html.endForm }}
</div>
