{% extends 'base/template.html' %}
{% block breadcrumb %}
    <ul class="breadcrumb">
        <li><a href="#!name=/{{ model_name }}">{{ model_verbose_name }}</a></li>
        <li class="active">{{ object }}</li>
    </ul><!-- /.breadcrumb -->
{% endblock %}

{% block content %}
    <form class="form-horizontal" role="form" method="POST" name="{{ model_name }}Form" id="{{ model_name }}Form">
        {% csrf_token %}
        <input type="hidden" name="id" value="{{ object.id }}"/>
        {% block additon-fields-pre %}{% endblock %}
        {% for field in form %}
            {% if channel and field.name == 'channel' %}
                <input type="hidden" name="channel" value="{{ channel.id }}"/>
            {% else %}
                {% if field.help_text %}
                    <div class="form-group" id="form-group-{{ field.name }}-help-text">
                        <label class="col-sm-3 control-label no-padding-right"></label>
                        <div class="col-sm-9 ">
                            <label class="alert-block alert-success">{{ field.help_text }}</label>
                        </div>
                    </div>
                {% endif %}
                <div class="form-group" id="form-group-{{ field.name }}">
                    <label class="col-sm-3 control-label no-padding-right" for="id_{{ field.name }}">
                        {% if field.field.required %}
                            <label style="color:red">*</label>
                        {% endif %}
                        {{ field.label_tag }}
                    </label>
                    <div class="col-sm-9">
                        {{ field }}
                        {% if field.errors %}
                            <span class="help-inline col-xs-12 col-sm-7"><span
                                    class="label label-danger">{{ field.errors }}</span></span>
                        {% endif %}
                    </div>
                </div>
                <div class="space-4"></div>
            {% endif %}
        {% endfor %}
        {% block additon-fields-post %}{% endblock %}
        {% block form-actions %}
            {% if editable %}
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="button" onclick="ajaxSubmit(this.form)">
                            <i class="ace-icon fa fa-check bigger-110"></i> 保存
                        </button>
                        <button class="btn btn-primary" type="button" onClick="history.go(-1);">
                            <i class="ace-icon fa fa-mail-reply bigger-110"></i> 返回
                        </button>
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i> 重置
                        </button>
                        {% if object.id %}
                            <a href="#!name=/{{ model_name }}/{{ object.id }}?clone" class="btn btn-success">
                                <i class="ace-icon fa fa-files-o bigger-110"></i> 复制
                            </a>
                        {% endif %}
                    </div>
                </div>
            {% endif %}
        {% endblock %}
    </form>
    {% block form-script %}
        <script language="JavaScript">
            $("[id^='id_']").each(function () {
                $(this).addClass("col-xs-10 col-sm-5");
            });
        </script>
    {% endblock %}
    {% block post-form-script %}{% endblock %}
{% endblock %}

{% block script %}
    {% include "base/scripts.html" %}
{% endblock %}