{% extends 'obj_form.html' %}

{% block js %}
        {{ block.super }} 

        $('#image-clear_id,#id_image').removeClass('form-control');

        $('.btn-save').click(function(){
            $.SubmitForm('#obj_form form','{{request.path}}',function (){
                $('.alert').fadeIn();
                setTimeout(function (){
                    $('.alert').fadeOut();
                },3000)
            });
        });  

        
    $('#obj_form .product_photo a').click(function(event){      
        event.preventDefault();
        var src=$(this).attr('href');
        var i="<div style='text-align:center;'><img src='"+src+"' style='height:400px;'></img></div>";
        $.OpenCfmDlg($('#id_name').val(),i);                   
    });
{% endblock %}
{% block form_content %}
    <div class="form-group product_photo">
        <label class="col-sm-2 control-label ">图片上传</label>
        <div class="col-sm-8">
        {% if form.instance.image %}
        <img src="{{form.instance.image.url}}" style="width:100px" />
        {% endif %}
            <div>
                {{ form.image }}
            </div>
         </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">是否开启</label>
        <div class="col-sm-1">
            <div>
                {{ form.is_active }}
            </div>
        </div>
    </div>
    <div class="alert alert-success" role="alert" style="display: none">保存成功！</div>
    <div>
        <a class="btn btn-primary btn-save" type="button" style="float:right;">保存</a> 
    </div> 
{% endblock %}