Note: Episerver Forms is only supported by MVC-based websites and HTML5-compliant browsers.
Episerver Forms actors
After a visitor submits a form, Forms.Core calls Actors to perform additional processing on the server.
- You can extend and plug in the Actor, and a third-party developer can implement it.
- You can run Actors in a sync or async manner.
- Each actor is provided with several data, including SubmissionData and the HttpRequest.
- Sync-actor can have (and can modify) the HttpResponse, so Actor can modify response and cookie before sending back result to a visitor's browser.
By default, Episerver Forms has two built-in Actors:
Handling submission actor's result (New in Forms 4.16.0)
From version 4.16.0, it is possible to allow actors to:
- Return a signal to cancel a form submission in the case where an actor fails.
- Return an error message to be displayed to visitors.
To be able to cancel form submissions and to display error messages, you need to implement the following changes:
- Actors must implement ISyncOrderedSubmissionActor. Actors implementing this interface run synchronously in ascending order, regardless of the IsSyncedWithSubmissionProcess value. (Actors are forced to run synchronously because we cannot control the result of async actors).
- Actors must return an object instance of a class which implements EPiServer.Forms.Core.PostSubmissionActor.Internal.ISubmissionActorResult.
By implementing this interface, the returned result will have two properties:
- CancelSubmit (boolean): determines whether the form submission should be canceled or not.
- ErrorMessage (string): this error message will be displayed to visitors.
Implementing customized actors
Basically, third-party developer can implement his own Actor by:
- Inheriting a PostSubmissionActorBase base class.
- Starting from scratch with the IPostSubmissionActor interface and interface IUIPropertyCustomCollection for edit view user interface of configuring the Actor model.
See a code sample about implementing a new Actor in open-source at https://github.com/episerver/EPiServer.Forms.Demo
Last updated: Sep 14, 2018