예제 #1
0
        public static ScopedHtmlHelper <TPostModel> FormFor <TViewModel, TPostModel>(this HtmlHelper <TViewModel> helper, TPostModel postModel, Action <FormTag> mutator = null)
        {
            var form = new FormTag();

            form.AddClasses("sg-form").NoClosingTag();

            if (mutator != null)
            {
                mutator(form);
            }

            helper.ViewContext.Writer.Write(form.ToHtmlString());

            return(helper.ForModel(postModel, () =>
            {
                helper.ViewContext.Writer.Write($"</{form.TagName()}>");
            }));
        }