{% extends request.is_ajax|yesno:'base_ajax.html,base.html' %}
{% load widget_tweaks %}

{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Person{% endif %}{% endblock %}

{% block content %}
    <div class="col-sm-offset-1 col-sm-10">
        <h3>{{ object.pk|yesno:"Edit,Add" }} Person</h3>

        <form action="{{ form.action|default:request.path }}" method="post" class="form-horizontal">{% csrf_token %}
            <div class="row">
                {% include 'form_errors.html' %}
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="{{ form.name.id_for_label }}"
                               class="col-sm-2 control-label">{{ form.name.label }}</label>

                        <div class="col-sm-10">
                            {% render_field form.name class+="form-control" placeholder=form.name.label %}
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="{{ form.phone.id_for_label }}"
                               class="col-sm-2 control-label">{{ form.phone.label }}</label>

                        <div class="col-sm-10">
                            {% render_field form.phone class+="form-control" type="tel" placeholder=form.phone.label %}
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="{{ form.email.id_for_label }}"
                               class="col-sm-2 control-label">{{ form.email.label }}</label>

                        <div class="col-sm-10">
                            {% render_field form.email class+="form-control" type="email" placeholder=form.email.label %}
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="{{ form.address.id_for_label }}"
                               class="col-sm-2 control-label">{{ form.address.label }}</label>

                        <div class="col-sm-10">
                            {% render_field form.address class+="form-control" placeholder=form.address.label %}
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label for="{{ form.notes.id_for_label }}"
                               class="col-sm-2 control-label">{{ form.notes.label }}</label>

                        <div class="col-sm-10">
                            {% render_field form.notes class+="form-control" placeholder=form.notes.label %}
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input class="btn btn-primary pull-right" type="submit"/>
            </div>
        </form>
    </div>
{% endblock %}