Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lonehorseend 24 posts 71 karma points
    Mar 21, 2015 @ 20:30
    lonehorseend
    0

    Mutiple forms on one page - Html.BeginUmbracoForm question

    Based on this thread, https://our.umbraco.org/forum/developers/razor/40066-Model-binding-problem-when-multiple-forms-on-the-same-page-, I found http://code.lawrab.com/2012/05/using-bind-prefix-in-aspnet-mvc.html and was able to create pre-faced fields for two different forms on the same page. But now I'm stuck on the partial recognizing those pre-faced fields so that the form will process.

    Here's the action line out of my controller:

            [HttpPost]
            public ActionResult TopSendEmail([Bind(Prefix = "TopBlogSub")] NewsletterModel model)

    Here's the line calling the partial:

    @Html.Partial("TopNLForm", new BCW.NewsletterModel(),  new ViewDataDictionary { TemplateInfo = new TemplateInfo { HtmlFieldPrefix = "TopBlogSub" } })

    Here's the Inherients line out of my partial

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<BCW.NewsletterModel>

    Here's the BeginUmbracoForm line out of my partial:

    Html.BeginUmbracoForm("TopSendEmail", "NewsletterSurface")

    What do I need to change in the HTML.BeginUmbracoFrom to so that it recognizes the prefaced fields? Or do I need to change the fields themselves?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 28, 2015 @ 16:03
    Alex Skrypnyk
    0

    Hi lonehorseend ,

    You have to change ids and names of input fields inside the form. Like that :

    id="

    Thanks

  • Daniel Bardi 927 posts 2562 karma points
    Mar 31, 2015 @ 07:32
    Daniel Bardi
    0

    You should be able to add html attributes and set the id of the form in the params of the BeginUmbracoForm

Please Sign in or register to post replies

Write your reply to:

Draft