Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CustomDefaultPlaceHolderProvider for Episerver Forms, build your own Summary in Episerver Forms EmailActor
using EPiServer.Forms.Core;
using EPiServer.Forms.Core.Internal;
using EPiServer.Forms.Core.Models;
using EPiServer.Forms.Core.Models.Internal;
using EPiServer.ServiceLocation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Gosso.EPiServerTestSite.Business
{
public class CustomDefaultPlaceHolderProvider : DefaultPlaceHolderProvider, IPlaceHolderProvider
{
private readonly Injected<IFormRepository> _formRepository;
public new IEnumerable<PlaceHolder> ExtraPlaceHolders
{
get
{
return new PlaceHolder[] { new PlaceHolder("friendlysummary", string.Empty) };
}
}
public new IEnumerable<PlaceHolder> ProcessPlaceHolders(IEnumerable<PlaceHolder> availablePlaceHolders, FormIdentity formIden, HttpRequestBase requestBase, Submission submissionData, bool performHtmlEncode)
{
IEnumerable<PlaceHolder> plh = base.ProcessPlaceHolders(availablePlaceHolders, formIden, requestBase, submissionData, performHtmlEncode);
Type[] excludedElementBlockTypes = new Type[] { typeof(IExcludeInSubmission) };
IEnumerable<FriendlyNameInfo> friendlyNameInfos = this._formRepository.Service.GetFriendlyNameInfos(formIden, excludedElementBlockTypes);
foreach (PlaceHolder holder in availablePlaceHolders)
{
if (holder.Key == "friendlysummary")
{
holder.Value = this.GetFriendlySummaryTextWithoutHiddenFields(friendlyNameInfos, performHtmlEncode ? "<br />" : Environment.NewLine, requestBase, submissionData);
}
}
return plh;
}
//// Overriding default SummaryText
//protected new string GetFriendlySummaryText(IEnumerable<FriendlyNameInfo> friendlyNames, string lineSeparator, HttpRequestBase requestBase, Submission submissionData)
//{
// //IEnumerable<FriendlyNameInfo> names = friendlyNames.Where(u => !u.FriendlyName.ToLowerInvariant().StartsWith("hidden")).ToList();//remove hidden fields
// var str = "Hijacked! <br/>" + base.GetFriendlySummaryText(friendlyNames, lineSeparator, requestBase, submissionData);
// return str;
//}
protected string GetFriendlySummaryTextWithoutHiddenFields(IEnumerable<FriendlyNameInfo> friendlyNames, string lineSeparator, HttpRequestBase requestBase, Submission submissionData)
{
IEnumerable<FriendlyNameInfo> names = friendlyNames.Where(u => !u.FriendlyName.ToLowerInvariant().StartsWith("hidden")).ToList();//remove hidden fields
var str = "Hidden fields is not shown <br/>" + base.GetFriendlySummaryText(names, lineSeparator, requestBase, submissionData);
return str;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.