{% extends 'base_metro.html' %}

{% block titulo %}{{ titulo|title }}{% endblock %}



{% block content %}

    <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon edit"></i><span class="break"></span>{{ nombre_app }} - {{ nom_modelo }}</h2>
                        <div class="box-icon">
                            <a href="#" class="btn-setting"><i class="halflings-icon wrench"></i></a>
                            <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
                            <a href="#" class="btn-close"><i class="halflings-icon remove"></i></a>
                        </div>
                    </div>
                    <div class="box-content">
                        <form class="form-horizontal" method="POST" enctype="multipart/form-data">
                          <fieldset>
                            {% csrf_token %}
                            {{ form.media }}
                             {% for field in form %}
                            <div class="control-group " id="{{field.label}}">
                                {{ field.is_required }}
                                {% if field.label == "Contenido" or field.label == "Descripcion" or field.label == "Observaciones" %}
                                                <label class="label-form-emiraldo col-md-3 col-sm-3 col-xs-12">{% if field.label == "Descripcion"  %}Descripción{% else %}{{ field.label }}{% endif %}
                                                    {% if field.field.required %}
                                                        <span class="required">*</span>
                                                    {% endif %}
                                                </label>
                                                <div class="col-md-8 col-sm-8 col-xs-11" style="margin-left: auto;margin-right: auto;">

                                                    {{ field }}
                                                    <span class="help-inline" style="">{{ field.help_text }}</span>
                                                    {% for error in field.errors %}
                                                    <span class="help-inline" style="color: red;">{{ error|escape }}</span>

                                                    {% endfor %}
                                                </div>
                                            {% else %}
                                                <label class="label-form-emiraldo col-md-3 col-sm-3 col-xs-12">{{ field.label }}
                                                    {% if field.field.required %}
                                                        <span class="required">*</span>
                                                    {% endif %}
                                                </label>

                                                <div class="col-md-6 col-sm-6 col-xs-12">

                                                    {{ field }}
                                                    <span class="help-inline" style="">{{ field.help_text }}</span>
                                                    {% for error in field.errors %}
                                                    <span class="help-inline" style="color: red;">{{ error|escape }}</span>

                                                    {% endfor %}
                                                </div>
                                            {% endif %}
                            </div>
                            {% endfor %}
                          <div class="form-actions">
                                <button type="submit" class="btn btn-primary">Guardar</button>
                                <a href="" class="btn cancelar" >Salir</a>
                          </div>
                          </fieldset>
                        </form>

                    </div>
                </div><!--/span-->

            </div><!--/row-->

{% endblock %}
{% block js %}
    <script>
        $('.cancelar').click(function(f){
            f.preventDefault();
            retorno=window.location.pathname.split('/');
            window.location.replace('/'+retorno[1]+'/'+retorno[2]);
        });
    </script>

{% endblock %}
