Copied to clipboard

Flag this post as spam?

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


  • Dan Evans 631 posts 1018 karma points
    Oct 07, 2013 @ 10:23
    Dan Evans
    0

    Accessing the name of a form in a masterpage

    I have this code to insert forms in pages. What I also need is the name of the form. How would I access this and place it in <h2>Form Name</h2>

    <% var formId = umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("form");
    if(formId != null){
    if(!string.IsNullOrEmpty(formId.Value)){ %>
     <div class="block-content">
    <div class="heading">
    <h2>Form Name</h2>
    </div>
    <umbraco:Macro FormGuid="[#form]" Alias="umbracoContour.RazorRenderForm" runat="server"></umbraco:Macro>
    </div>
    <% }
    }
    %>
  • Dan Evans 631 posts 1018 karma points
    Oct 08, 2013 @ 13:06
    Dan Evans
    100

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using Umbraco.Forms.Core

    @using Umbraco.Forms.Data.Storage

     

    @{

    FormStorage fs = new FormStorage();

    String formId = Parameter.FormGuid;

                Form f = fs.GetForm(new Guid(formId));

                fs.Dispose();

    <h2>@f.Name</h2>

         }

  • Comment author was deleted

    Oct 08, 2013 @ 18:01

    Yup, thanks for sharing the solution :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies