You can create your own DataSubmissionService
i.e.
public class CustomDataSubmissionService : DataSubmissionService
{
public override SubmitActionResult PerformDataSubmit(NameValueCollection rawSubmittedData,
HttpContextBase httpContext,
ControllerBase controller)
{
context.StructureMap().Configure(c =>
{
c.For<DataSubmissionService>().Use(new CustomDataSubmissionService());
});
Hi!
But if I remove the honeypot form field in the overridden PerformDataSubmit method I guess I won't be able to check if the honeypot form field has a value or not in my HoneypotActor.
It's in the HoneypotActor I check if the honeypot form field has a value (probably a spam robot has filled it in). If it has a value I cancel the submit.
I only want the honeypot form field to be excluded from "#summary" and stored form submissions.
public class HoneypotActor : PostSubmissionActorBase, ISyncOrderedSubmissionActor
{
public int Order => 1;
public override object Run(object input)
{
var formContainerBlock = FormIdentity.GetFormBlock();
var formElements = formContainerBlock.Form.Steps.SelectMany(st => st.Elements);
var honeypotElements = formElements.Where(elem => elem.SourceContent is HoneypotElementBlock).ToList();
if (honeypotElements.Any())
{
foreach (var honeypotElement in honeypotElements)
{
if (!string.IsNullOrEmpty(SubmissionData.Data[honeypotElement.ElementName]?.ToString()))
{
var formId = formContainerBlock.Content.ContentLink.ID;
var result = new SubmissionActorResult
{
CancelSubmit = true,
ErrorMessage = LocalizationService.Current.GetString("/blocks/honeypotelementblock/errormessage")
};
return result;
}
//Remove data for HoneyPotElement from final data.
SubmissionData.Data.Remove(honeypotElement.ElementName);
}
}
return "";
}
}
Best regards
Kristian