Last active
May 15, 2020 14:13
-
-
Save AThraen/50e90be26e2d753bbbd2a87f349506f2 to your computer and use it in GitHub Desktop.
Actor that adds additional system fields to Episerver Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using EPiServer; | |
| using EPiServer.Core; | |
| using EPiServer.Forms.Core.PostSubmissionActor; | |
| using EPiServer.Forms.Core.PostSubmissionActor.Internal; | |
| using EPiServer.ServiceLocation; | |
| using EPiServer.Web.Routing; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| namespace Alloy.Business.Forms | |
| { | |
| public class EnrichFormSubmissionActor : PostSubmissionActorBase | |
| { | |
| protected Injected<IContentRepository> _contentRepo { get; set; } | |
| protected Injected<UrlResolver> _urlResolver { get; set; } | |
| public override object Run(object input) | |
| { | |
| //Actor that looks up the proper Content object / page where the form is located and adds that to the form data. | |
| var page = this.SubmissionData.Data[EPiServer.Forms.Constants.SYSTEMCOLUMN_HostedPage]; | |
| if (!string.IsNullOrEmpty((string)page)) | |
| { | |
| var pd = _contentRepo.Service.Get<PageData>(ContentReference.Parse((string)page)); | |
| SubmissionData.Data.Add("SYSTEMCOLUMN_PageTitle", pd.Name); | |
| SubmissionData.Data.Add("SYSTEMCOLUMN_PageUrl", _urlResolver.Service.GetVirtualPath(pd.ContentLink).VirtualPath); | |
| } | |
| var result = new SubmissionActorResult(); | |
| result.CancelSubmit = false; | |
| return result; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment