示例#1
0
        public static MvcForm BeginForm(this HtmlHelper html, string controller = null, string action = null, Action <FormTag> config = null, object routeValues = null)
        {
            var form = new FormTag();

            form.Method("POST");

            if (controller.IsNullOrEmpty())
            {
                controller = html.ViewContext.GetControllerName();
            }

            if (action.IsNullOrEmpty())
            {
                action = html.ViewContext.GetActionName();
            }

            if (config != null)
            {
                config(form);
            }
            form.Action(UrlHelper.GenerateUrl(null, action, controller, new RouteValueDictionary(routeValues),
                                              html.RouteCollection, html.ViewContext.RequestContext, true));
            form.NoClosingTag();
            html.ViewContext.Writer.Write(form.ToString());
            return(new MvcForm(html.ViewContext));
        }
        public override HtmlTag Build(FormRequest request)
        {
            var tag = new FormTag(request.Url);

            tag.NoClosingTag();

            return(tag);
        }
示例#3
0
        public HtmlTag Build(ElementRequest request)
        {
            var naming = request.Get <ElementNaming>();

            var formTag = new FormTag();

            if (request.Model != null)
            {
                formTag
                .Id(naming.Form(request.Model))
                .Attr("data-form-summary", naming.FormSummaryId(request.Model));
            }

            return(formTag
                   .NoClosingTag()
                   .Attr("data-controller", "form"));
        }