Overriding and Extending the Sitefinity Forms Builder Widget

by Gregg Crystal Nov 28, 2016

One of Sitefinity's greatest features is the ability to override and extend the built in functionality, such as Lists, Blogs, and Forms widgets.

This lets you change not only the presentation of these components, but the functionality of them as well.

Example

Here's an example of overriding the built in FormsControl (this is a WebForms example):

First, create a class and derive it from Sitefinity's FormsControl class (you can look up what the built in widgets' classes' are from the ToolboxesConfig.Config file).

Then, to override and change functionality simply type override and select the function you want to override:

sf-blog-extend-widgets-01.png

Here I'm overriding the ProcessFormSaving function, which is the method that saves the submitted Form Data to the database.

I added some code to pull the data out of the Form, and I'm going to do something else with it.

I commented out the call to base.ProcessFormSaving. I could have also just extended this method by adding some more functionality and calling the original (base) method. But I here I've decided not save the Form data to the database.

sf-blog-extend-widgets-02.png

If you're wondering what each method does or how internal code works, you can always use Telerik's JustDecompile to look at the internal source.

Also note that I've added a CustomProperty field. Any public getter/setter in a control is going to automatically appear in Sitefinity's advanced view in the widget designer.

This is a quick and easy way to allow the user to be able to add some additional customizable data to the widget, and then use that value in code.

You can see the property here, in the Widget Designer:

sf-blog-extend-widgets-03.png

I should also note I then added this control as a custom control to ToolboxesConfig.Config. It shows up in the list of modules that you can drag onto a page.

With the ability to extend Sitefinity's built-in functionality, you have unlimited potential to customize your website.

Ready to Supercharge Your Sitefinity Project?