Skip to content

Instantly share code, notes, and snippets.

@avisra
Created April 13, 2013 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avisra/5376951 to your computer and use it in GitHub Desktop.
Save avisra/5376951 to your computer and use it in GitHub Desktop.
Sitefinity's Form Builder allows users to create forms on the fly. This code snippet is for overriding the default control for Form Builder forms. This allows you to attach to the save event of the form so that you can process data when the form is submitted. This works well for instances where you need to capture lead data for sending to a CRM.
public class CustomFormsControl : FormsControl
{
protected override void InitializeControls(GenericContainer container)
{
base.InitializeControls(container);
// Attaches to the FormSaved event to run custom code upon submitting a Form Builder form.
this.FormSaved += new EventHandler<System.EventArgs>(CustomFormsControl_FormSaved);
}
private void CustomFormsControl_FormSaved(object sender, EventArgs e)
{
// Loop through each of the fields in the Form Builder form
foreach (IFormFieldControl fieldControl in this.FieldControls)
{
var field = fieldControl as FieldControl;
var value = field.Value; // submitted value for the form field
// Any custom code that needs to process can go here.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment