Skip to main content
Version: 2026.1

Form Field Extension Logic

In this article we will show you how to create a Form Field Extension Logic. If you would like to learn about creating Form Field Extension JS it is described with details in this article. Also in this article you can find description how to combine Logic and JS part of Form Field Extension.

Creating Form Field Extension Logic

Right click on the project in the solution and select Add -> New Item. From this window we can select Form Field Extension Logic option and specify name of our logic class. In this example, we will name it PhoneNumberLogic.

New form field extension logic

After clicking the Add button, a popup will be appear which will ask you for some details about this plugin. The model class can be defined in order to be able to interact between our logic class and JS part. In this case we select Object (referencing default BPS Type).

Choose model type

Model determines the model used in the methods of the logical part and the data model passed to the interface part. Selection of a type other than the default BPS Type requires implementation of the interface part as well.

  • Object (referencing default BPS Type) - control value stored as an object type but the actual type is the type corresponding to the database type of the field (string,decimal etc.)
  • System type - control value stored as a one of the system type, e.g. integer, string, DateTime,
  • New class - control value stored in an object of a custom class.

After clicking OK button, file with logic class and configuration will be generated in your project. In this example we will have PhoneNumberLogic.cs and PhoneNumberLogicConfig.cs.

Extension Logic

Now let's focus on the PhoneNumberLogic.cs file. As you can see PhoneNumberLogic derives from FormFieldExtension generic class of our newly created PhoneNumberLogicConfig class. This generic abstract class contains set of virtual methods that you can override in order to provide your custom implementations, e.g.

  • public override object ConvertToDBType(string dbValue),
  • public override Task<T> ConvertToControlTypeAsync(object value)
  • public override Task<object> ConvertToDBTypeAsync(T value)
  • public override object OnDBValueSet(object valueToSet),
  • public override object OnDBValueGet(object dbValue),
  • public virtual Task OnAfterElementSaveAsync(AfterSaveParams<FormFieldExtensionContext> args).
  • public virtual Task OnBeforeElementDeleteAsync(BeforeDeleteParams<FormFieldExtensionContext> args),
  • public virtual Task OnBeforeElementSaveAsync(BeforeSaveParams<FormFieldExtensionContext> args),
  • public virtual Task ValidateAsync(ControlValidationParams<FormFieldExtensionContext> args),
  • public virtual Task VerifySaveRestrictionsAsync(ControlSaveRestrictionsParams<FormFieldExtensionContext> args).

In this example we override OnDBValueSet method to manipulate field value before it is saved id database. This example code is also available on our GitHub


public class PhoneNumberLogic : FormFieldExtension<PhoneNumberLogicConfig>
{

public override object OnDBValueSet(object valueToSet)
{
var stringValue = valueToSet as string;
stringValue = stringValue.Replace("-", "").Replace(" ", "");
return stringValue;
}
}

Configure Form Field Extension

Now you can publish SDK package and deploy it in Designer Studio. How to do that is described here. After deployment you are ready to configure Extension, this example extension have to be used on text field.

Choose model type

Test Form Field Extension

To test extension you can enter value with additional spaces and dashes and save element.

Choose model type

While saving element, all spaces and dashes will be removed before saving to the database. So after save it will look like this:

Choose model type