{% extends 'base.html' %}
{% load static %}
{% block title %}
    Edit Profile
{% endblock %}

{% block content %}
    <div class="col-lg-6 offset-3">
        <div class="box">
            <h3 class="heading">Edit Profile</h3>
            {% if form.errors %}
                {% for field in form %}
                    {% for error in field.errors %}
                        <div class="alert alert-danger alert-dismissable">
                            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                            <strong>{{ error|escape }}</strong>
                        </div>
                    {% endfor %}
                {% endfor %}
                {% for error in form.non_field_errors %}
                    <div class="alert alert-danger alert-dismissable">
                        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                        <strong>{{ error|escape }}</strong>
                    </div>
                {% endfor %}
            {% endif %}
            <form action="" method="post">
                {% csrf_token %}
                {% for field in form %}
                    {% if field.name == 'gender' %}

                        <div class="form-group">
                            <label for="gender">Gender</label>
                            <br>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" {% if field.value == 'male' %} checked {% endif %}
                                       type="radio" name="gender" id="male gender"
                                       value="male">
                                <label class="form-check-label" for="male">Male</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" {% if field.value == 'female' %} checked {% endif %}
                                       type="radio" name="gender" id="female"
                                       value="female">
                                <label class="form-check-label" for="female">Female</label>
                            </div>
                        </div>

                    {% else %}

                        <div class="form-group">
                            <label for="id_{{ field.name }}">{{ field.label }}</label>
                            <input type="{{ field.field.widget.input_type }}"
                                   class="form-control"
                                   name="{{ field.name }}"
                                   id="id_{{ field.name }}"
                                   value="{{ field.value }}"
                                   placeholder="{{ field.field.widget.attrs.placeholder }}">
                        </div>

                    {% endif %}
                {% endfor %}
                <div class="text-center">
                    <button type="submit" class="btn btn-outline-white-primary">
                        <i class="fa fa-signing"></i> Update
                    </button>
                </div>
            </form>
        </div>
    </div>
{% endblock %}