BootstrapExtensions.Base.Form.FormExtensions.GenerateForm C# (CSharp) Method

GenerateForm() private static method

private static GenerateForm ( this htmlHelper, string formAction, FormMethod method, object>.IDictionary htmlAttributes, FormLayout layout ) : System.Web.Mvc.Html.MvcForm
htmlHelper this
formAction string
method FormMethod
htmlAttributes object>.IDictionary
layout FormLayout
return System.Web.Mvc.Html.MvcForm
        private static MvcForm GenerateForm(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary<string, object> htmlAttributes, FormLayout layout)
        {
            var tagBuilder = new TagBuilder("form");
            tagBuilder.MergeAttributes(htmlAttributes);
            tagBuilder.MergeAttribute("action", formAction);
            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);

            if (layout != FormLayout.Default)
                tagBuilder.AddCssClass("form-" + layout.ToString().ToLower());
            htmlHelper.ViewContext.TempData["BootstrapFormLayout"] = layout;

            var flag = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled;
            if (flag) tagBuilder.GenerateId(GenerateId(htmlHelper.ViewContext));
            htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag));
            var mvcForm = new MvcForm(htmlHelper.ViewContext);
            if (flag) htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"];
            return mvcForm;
        }