@{
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, user);
    string guid = Html.Guid();
}
<div class="main">
    <form method="post" class=" form  ui-formBind" data-source="@Model">
        <div class="form-group">
            <label class="control-label">类别名称</label>
            <div class="controls">
                <input type="text" id="Name" name="Name" maxlength="50" class="form-control" data-validate="dataType:'*',nullMsg:'请填写会员组名称!'" />
                <span class="help-block"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">备注</label>
            <div class="controls">
                <input type="text" id="Remark" name="Remark" maxlength="50" class="form-control" />
                <span class="help-block"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">注册</label>
            <div class="controls">
                <select name="CanReg" class="form-control form-control-xs" id="CanReg">
                    <option value="1">开放注册</option>
                    <option value="0">禁止注册</option>
                </select>
                <span class="help-block"></span>
            </div>
        </div>

        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", "admin");
            data.Add("guid", guid);
            data.Add("currentUser", ViewBag.CurrentUser);
            data.Add("i", 0);
            int i = 0;
            if (fieldData != null)
            {
                foreach (var row in fieldData)
                {
                    data["i"] = i;
                    beforeSubmitJs += row.BeforeSubmitJs;
                    Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                    i++;
                }
            }
        }
        <script type="text/javascript">
            function BeforeSubmit() {
                @Html.Raw(beforeSubmitJs)
                return true;
            }
        </script>
        <div class="form-group">
            <label class="control-label">等级</label>
            <div class="controls">
                <input type="text" id="Rank" name="Rank" maxlength="3" data-validate="dataType:'numeric',min:1,nullMsg:'请填写会员等级!',errorMsg:'只能填写大于等于1的数字！'" class="form-control form-control-xs" />
                <span class="help-block"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label"></label>
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" id="IsDefault" name="IsDefault" value="0" />
                <input type="hidden" id="Id" name="Id" />
                <input type="hidden" id="Guid" name="Guid" value="@guid" />
                <button type="button" class="btn btn-sm btn-primary ui-pagePost" data-custom-params="url:'@Url.Action()',callBack:'PostRefreshBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>
