Episerver Forms Override Form Submit

Vote:
 

I have been trying to override the default form submission controller so that we can intercept certain fields, and mask the values being saved (I.e. Credit card information) only to store the last 4 or stop them from beings saved altogether. The information will also be sent to a third party to handle the processing. I have followed the Epi demo but have not had any luck. This will not hit my custom controler no matter what I Do. 

Controller

    [ServiceConfiguration(typeof(IDataSubmitController))]
    public class FormSubmissionController : DataSubmitController
    {
        public ActionResult Index()
        {
            return null;
        }

        public override ActionResult Submit()
        {
            var t = 5;
            return base.Submit();
        }
    }

Initialization Module

 [InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class SiteInitialization : IConfigurableModule
    {
        public void Initialize(InitializationEngine context)
        {
            GlobalFilters.Filters.Add(new HandleErrorAttribute());

            context.Locate.DisplayChannelService().RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile)
            {
                ContextCondition = r => r.GetOverriddenBrowser().IsMobileDevice
            });
        }

        public void Uninitialize(InitializationEngine context){}


        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Container.Configure(c =>
            {
                c.For().Use(new FormSubmissionController());
                c.For().Use();
                c.For().Use();
                c.For().Use();
                c.For().Use();
            });

            DependencyResolver.SetResolver(new StructureMapDependencyResolver(context.Container));
            
        }
    }
#147961
Apr 28, 2016 18:27
Vote:
 

using Forms version 2.0.0.2

#147962
Apr 28, 2016 19:34
Vote:
 

Does changing the Forms configuration solve your problem?

Look at modules\_protected\EPiServer.Forms and

<episerverforms coreController="/EPiServer.Forms/DataSubmit" />

Try change that to the path of your own Controller

#148224
May 06, 2016 12:06
Vote:
 

Are you sure you need to override the entire submit? You can always use Form Events to intercept the post form submit events and interact with the form data that way:

[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class FormEventsInit : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        FormsEvents.Instance.FormsSubmitting += Instance_FormsSubmitting;
    }

    private void Instance_FormsSubmitting(object sender, FormsEventArgs e)
    {
        // The event fires before the data is submitted so there is an opportunity to interact here
        var formData = e.Data;
    }

    public void Uninitialize(InitializationEngine context) { }
}


 

#148228
May 06, 2016 14:37
Vote:
 

Or also create your own Actor http://world.episerver.com/add-ons/episerver-forms/implementing-a-customized-actor/

All depending on what you want to do on submit.

I would say

* Take full control over submitting: Custom Controller

* Read/adjust information as it is posted: Event

* Just have a "store/send" submitted data: Actor

#148243
May 06, 2016 17:37
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.