{% extends 'base.html' %}
{% load static %}
{% load bootstrap %}
{% block custom_head_css_js %}
    <link href="{% static "css/plugins/chosen/chosen.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/chosen/chosen.jquery.min.js" %}"></script>
{% endblock %}

{% block content %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>填写用户组信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" id="userForm" class="form-horizontal" action="" >
                            {% csrf_token %}
                            {{ form.name|bootstrap_horizontal }}

                            <div class="form-group">
                                <label for="users" class="col-sm-2 control-label">用户</label>
                                <div class="col-sm-8">
                                    <select name="users" id="users" data-placeholder="选择用户" class="chosen-select form-control m-b" multiple  tabindex="2">
                                        {% for user in users %}
                                            <option value="{{ user.id }}">{{ user.name }}</option>
                                        {% endfor %}
                                    </select>
                                    <span class="help-block m-b-none">用户和用户组必选一个</span>
                                </div>
                            </div>

                            {{ form.comment|bootstrap_horizontal }}

                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-white" type="reset">取消</button>
                                    <button id="submit_button" class="btn btn-primary" type="submit">确认保存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block custom_foot_js %}
    <script>
        $(document).ready(function () {
            var config = {
                '.chosen-select'           : {},
                '.chosen-select-deselect'  : {allow_single_deselect:true},
                '.chosen-select-no-single' : {disable_search_threshold:10},
                '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
                '.chosen-select-width'     : {width:"95%"}
            };
            for (var selector in config) {
                $(selector).chosen(config[selector]);
            }
        })
    </script>
{% endblock %}