Copied to clipboard

Flag this post as spam?

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


  • Matthew Kirschner 323 posts 611 karma points
    Jun 01, 2017 @ 21:22
    Matthew Kirschner
    2

    Get form name in email template

    How do I get the form name in a custom, Umbraco Forms email template?

    My first thought was to use the GetField method of the FormsHtmlModel passed to the view, but I don't know what the key for form name would be. I've tried "formName" and "form_name" to no avail.

  • John Churchley 272 posts 1258 karma points c-trib
    Jul 16, 2017 @ 20:58
    John Churchley
    0

    Did you work this out?

    I did it myself by creating a hidden field with default value but there must be a more elegant solution.

  • Matthew Kirschner 323 posts 611 karma points
    Jul 17, 2017 @ 13:28
    Matthew Kirschner
    1

    Hi, John.

    I'm not using the Forms Email Templates until they add these features back in. It's like one step forward and two steps back with every new update.

    Instead, I've started using the PerplexMail package, which provides a Forms Workflow out of the box. I had to tweak a file to get the recordID and form name in the email template, but the package is open source so this was relatively easy. Let me know if you need help.

  • denisedelbando 141 posts 339 karma points
    Oct 02, 2017 @ 13:51
    denisedelbando
    0

    did they get rid of it?

  • Chris Smith 38 posts 141 karma points
    Sep 05, 2019 @ 11:13
    Chris Smith
    1

    Sorry for the bump, did this ever get resolved? I'm also trying to add the form name to the email template the customer will receive but without any luck.

    My last try was;

    @Model.GetValue("form_name")
    

    Cheers

    Chris

  • Jeremias 53 posts 278 karma points
    Nov 26, 2019 @ 08:49
    Jeremias
    1

    Hello,

    now I have a solution, that works for me:

    @{
        var uHelper = new UmbracoHelper(UmbracoContext.Current);
        Umbraco.Forms.Data.Storage.FormStorage formStorage = new Umbraco.Forms.Data.Storage.FormStorage();
        var formId = new Guid(uHelper.AssignedContentItem.GetPropertyValue<string>("form"));
        var form = formStorage.GetForm(formId);
    }
    <h2>@form.Name</h2>
    

    UmbracoAssignedContentItem is the page where you have picket the Form. So I get the guid from the form. With this the form and the Name of the form.

    I hope this helps you, too!

  • Matthew Kirschner 323 posts 611 karma points
    Nov 26, 2019 @ 15:57
    Matthew Kirschner
    0

    Thanks for the work-around, Jeremias.

    Here's what I went with:

    @inherits UmbracoViewPage<Umbraco.Forms.Core.Models.FormsHtmlModel>
    
    @{
        // Get form name
        var formStorage = new Umbraco.Forms.Data.Storage.FormStorage();
        var form = formStorage.GetForm(Model.FormId);
        var formName = form.Name;
    }
    
  • Diedrik Kuypers 3 posts 73 karma points
    Feb 11, 2020 @ 08:55
    Diedrik Kuypers
    0

    Hi,

    I'm trying to reuse a single template for multiple forms, and would like to get the form name into the email template. When I try your example code, I get the following error.

    The type or namespace name 'FormStorage' does not exist in the namespace 'Umbraco.Forms.Data.Storage'``

    How do we access the FormStorage in the latest Umbraco Forms version?

  • Chris Speakman 17 posts 151 karma points
    May 21, 2020 @ 11:42
    Chris Speakman
    0

    Did you ever find an answer to this Diedrik?

    I'm trying to do exactly the same as you with a re-usable template but FormStorage appears to be an internal class now.

    Is there an alternative way of getting the form name?

  • Frans de Jong 548 posts 1840 karma points MVP 3x c-trib
    Feb 11, 2020 @ 09:53
    Frans de Jong
    0

    There is more information about how to get this info here:

    https://github.com/umbraco/Umbraco.Forms.Issues/issues/33

    If you need more information in the template you need to add a new feature request. there

Please Sign in or register to post replies

Write your reply to:

Draft