{% from 'forms/_form.html' import form_header, form_rows, form_footer, form_fieldset %}

{{ form_header(form) }}
{% call form_fieldset(_('User information'), render_as_fieldset=indico_config.LOCAL_IDENTITIES) %}
    {{ form_rows(form, fields=('first_name', 'last_name', 'email', 'affiliation', 'create_identity')) }}
{% endcall %}
{% if indico_config.LOCAL_IDENTITIES %}
    {% call form_fieldset(_('Login details'), id='create-account-login-details') %}
        {{ form_rows(form, fields=('username', 'password', 'confirm_password')) }}
        {{ template_hook('below-user-admin-create-form') }}
    {% endcall %}
{% endif %}
{% call form_footer(form) %}
    <input class="i-button big highlight" type="submit" value="{% trans %}Save{% endtrans %}">
    <button type="button" class="i-button big" data-button-back>{% trans %}Cancel{% endtrans %}</button>
{% endcall %}

<script>
    (function() {
        'use strict';

        var fieldset = $('#create-account-login-details');
        $('#create_identity').on('change', function() {
            fieldset.toggle(this.checked);
        }).triggerHandler('change');
    })();
</script>
