@{
    string guid = Html.Guid(); //编辑页从信息数据中读取
    string table = ViewBag.Table;
    CurrentUser currentUser = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, currentUser);
}
<div class="main">
    <form class=" form-group-sm form ui-validForm" method="post" data-validate-params="beforeSubmit:'BeforeSubmit'" data-source="@Model">
        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", "admin");
            data.Add("currentUser", currentUser);  //当前用户
            data.Add("i", 0);
            int i = 0;
            foreach(var item in fieldData)
            {
                data["i"] = i;
                beforeSubmitJs += item.BeforeSubmitJs;
                Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)item, data);
                i++;
            }
        }
        <div class="form-group top_menu_disable">
            <label class="control-label radio" for="IsFinal">最终分类</label>
            <div class="controls">
                <label class="radio-inline"><input type="radio" name="IsFinal" id="IsFinal" value="1" checked>是</label>
                <label class="radio-inline"><input type="radio" name="IsFinal" id="IsFinal" value="0">否</label>
                <span class="help-block">设置为最终分类后当前分类不能添加子类</span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label" for="State">是否启用</label>
            <div class="controls radio">
                <label class="radio-inline"><input type="radio" name="State" id="State" value="1" checked>是</label>
                <label class="radio-inline"><input type="radio" name="State" id="State" value="0">否</label>
            </div>
            <span class="help-block"></span>
        </div>

        <div class="form-group">
            <label class="control-label" for="Xuhao">序号</label>
            <div class="controls">
                <input type="text" name="Xuhao" id="Xuhao" maxlength="3" value="1" class="form-control form-control-xs ui-queryString" data-validate="dataType:'numeric'">
                <span class="help-block"></span>
            </div>
        </div>

        <div class="form-group postarea">
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" name="Id" id="Id" value="0" />
                <input type="hidden" name="Level" id="Leve" value="1" />
                <input type="hidden" name="ParentId" id="ParentId" value="@Request.QueryString["parentId"]" />
                <input type="hidden" name="Guid" id="Guid" value="@guid" />
                <input type="hidden" name="_AttachmentFields" id="_AttachmentFields" value="@Html.GetAttachmentFields(table)" />
                <button type="button" class="btn btn-sm  btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',callBack:'PostRefreshBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    var id = Request("id");
    if (id>0) {
        $(".form").FormBind({dataSourceFrom:"attr"});
        $("input[name='IsFinal']").attr("disabled","disabled");
    }

    function BeforeSubmit() {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
</script>