<div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
    <form class="layui-form" action="" method="post" >
        <div class="layui-form-item">
            <label class="layui-form-label">分组名称</label>
            <div class="layui-input-inline" style="min-width: 200px;">
                <input type="text" value="{{.group.group_name}}" name="group_name" id="group_name" lay-verify="required" autocomplete="off" placeholder="资源分组" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分组说明</label>
            <div class="layui-input-inline" style="min-width: 300px;">
                <textarea name="description"  id="description" placeholder="请输入内容" class="layui-textarea">{{.group.description}}</textarea>
            </div>

        </div>
        <input type="hidden" id="id" name="id" value="{{.group.id}}">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    var $;
    layui.use(['form','element','layer','jquery'],function(){
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var $ = layui.jquery;
        var error_info = "{{.flash.error}}";
        if(error_info){
            layer.msg(error_info,{icon: 2,shade:0.5},function () {
                window.parent.layer.closeAll();
                window.parent.location.reload();
            })
            return;
        }
        form.on('submit(sub)', function(data){
            var form_data = $("form").serialize();
            $.post('{{urlfor "ServerGroupController.AjaxSave"}}', form_data, function (out) {
                if (out.status == 0) {
                    layer.msg("操作成功",{icon: 1,shade:0.5,time:1000},function () {
                        window.parent.layer.closeAll();
                        window.parent.location.reload();
                    })
                } else {
                    layer.msg(out.message)
                }
            }, "json");
            return false;
        });

        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();
    });
</script>