Knowledge Base

Creating custom submit actions


Configuration

Flex Form allows you to configure up to 3 custom "actions" that are executed when the form is submitted. You implement the functionality for actions in a class library. Actions must inherit the base class Dotcom.Modules.FlexForm.SubmitActionBase.

You configure the name of the class library assembly in module settings for the form. When you have done this, the names of any classes that inherit SubmitActionBase will appear in the three drop down lists that represent the custom actions that you want to execute for this instance of the form.

Action Settings

Each custom action class can be associated with an ASP.NET user control (.ascx) to capture and manage its own configuration settings. The settings control must inherit the class Dotcom.Modules.FlexForm.SubmitActionSettingsBase.

The action class property SubmitActionBase.SettingsControl allows you to specify the virtual path to its settings user control. When you select the action in the module configuration page, FlexForm will display your action class' settings UI.

SubmitActionBase.Execute(settings, values)

This method is called when the form is submitted. You use it to implement the functionality for your custom action. The method receives two arguments.

The first is a Hashtable of settings (FlexForm passes the PortalModuleBase.Settings property, including the settings associated with your action class).

The second argument is a Dictionary<string, object> of values. The dictionary is keyed using the ID of the controls configured on the form. The values are the values of the corresponding controls.

Your class can use these values to implement the functionality you need.

Data Validation

The SubmitActionBase.MandatoryFields property allows you to specify an array of data values that the action class requires in order to execute. The method DataValid(settings, values, errors) performs the validation. The default implementation in SubmitActionBase checks the values dictionary passed to it to ensure that a value exists for all mandatory fields. A collection of errors is returned naming any that don't.

You can override this method in your own action class to provide extra validation, for example, checking for the presence of configuration settings.



 |  View Topic History  |