Copied to clipboard

Flag this post as spam?

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


  • Phillip Turner 98 posts 412 karma points
    Apr 30, 2014 @ 05:48
    Phillip Turner
    1

    How to add a form id to Html.BeginUmbracoForm

    Hello Umbracians.

    v6.1.6, Mvc - Razor

    I am using @Html.BeginUmbracoForm("Action", Controller") to render a form and I thought I would be able to pass the following code to render a unique form ID:

    new { @id = "frmMainContact" }

    @Html.BeginUmbracoForm("Action", "Controller", new { @id = "frmMainContact" })
    

    Seems I was wrong.

    Does anyone know how to do this?

    Many thanks

    Phillip

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Apr 30, 2014 @ 13:20
    Steve Morgan
    0

    I've just tried this in v7.1 and it works fine as you have it. 

    Can I suggest you try explicitly stating the parameter name in case it's using the wrong overloaded method (not sure this is this even possible?):

    @Html.BeginUmbracoForm("Action","Controller", htmlAttributes: new{@id="frmMainContact"})

    Other things I tried was dropping the '@' and variants of case (e.g. Id and ID) - all were correctly output as " <form id="frmMainContact" ..>

     

     

  • Phillip Turner 98 posts 412 karma points
    Apr 30, 2014 @ 14:32
    Phillip Turner
    104

    I was missing a parameter.

    This worked for me:

    @Html.BeginUmbracoForm("Action", "Controller", null, new { @id = "frmMainContact" })
    

    Thanks for the reply!

Please Sign in or register to post replies

Write your reply to:

Draft