Skip to content

Instantly share code, notes, and snippets.

@alasvant
Created March 24, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alasvant/ed813a4d5ddd99931134077cd5ec5ff4 to your computer and use it in GitHub Desktop.
Save alasvant/ed813a4d5ddd99931134077cd5ec5ff4 to your computer and use it in GitHub Desktop.
Sample code for creating custom Episerver Forms form container block. This is the code part for the container block.
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.Forms.Core;
using EPiServer.Forms.Implementation.Elements;
using EPiServer.ServiceLocation;
using System.ComponentModel.DataAnnotations;
namespace SampleCustomFormContainer.Models.Forms
{
[ServiceConfiguration(typeof(IFormContainerBlock))]
[ContentType(DisplayName = "SiteFormsContainerBlock",
GUID = "0d416689-3819-4812-b40d-2bdd62ef7eba",
Description = "Episerver Forms container with GTM submit event support.",
GroupName = EPiServer.Forms.Constants.FormElementGroup_Container)]
public class SiteFormsContainerBlock : FormContainerBlock
{
[Display(Name = "GTM form name", Description = "Enter the Google Tag Manager submit event form name.", GroupName = CustomGroupNames.GtmTabName, Order = 10)]
[CultureSpecific(true), Required]
public virtual string GtmFormName { get; set; }
[Display(Name = "GTM category name", Description = "Enter the Google Tag Manager submit event category name.", GroupName = CustomGroupNames.GtmTabName, Order = 20)]
[CultureSpecific(true), Required]
public virtual string GtmCategoryName { get; set; }
}
[GroupDefinitions]
public static class CustomGroupNames
{
// for demo purposes to have this class here
// normally you have your sites tab definitions in one common place
[Display(Name = "Google Tag Manager", Order = 20)]
public const string GtmTabName = "custom-gtm";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment