Sitecore – Multistep forms in Webforms for Marketers: Part 2

In my previous post, I talked about how and why we wanted to try using Multistep forms in Webforms for Marketers (WFFM). This post is about creating the hidden field that we used to accomplish the multistep form in WFFM.

Adding a Field Type to Sitecore WFFM

Within Sitecore, the hidden field is created in the Master Database:

  1. Navigate to:  /sitecore/System/Modules/Web Forms For Marketers/Settings/Field Types/Custom
  2. Add a new “Field Type” object
  3. Set Assembly and Class fields to the class that drives the functionality (we create this class below, Code)
  4. Set User Control field if you are using a .ascx control to render the field (like email-confirm email field)

You can add this field in the form designer like any other field – it shows up in the drop down list when adding a field under the Custom section.

Coding

Next you have to create the code class to drive the rendering and functionality of the field (Referenced in step 2 above in Sitecore). I took the SingleLineText field in Sitecore.Forms.Custom.dll (class is Sitecore.Form.Web.UI.Controls.SingleLineText) and used .NET Reflector (shameless plug here) to get the code for rendering. So it’s not a true html hidden field – but this is just for a test and this a fast way to do it. Here’s a copy of our stripped down hiddenfield.cs (the code class is in the DelphicSage.Sitecore.Forms.Fields Namespace).

Within the OnInit Method,  I changed the CSS classes to new names (scfHiddenFieldTextBox, scfHiddenFieldGeneralPanel, scfHiddenFieldTextLabel, etc). The stylesheet was updated to hide the border wrapping, .scfHiddenFieldBorder { display: none; visibility: hidden; }. This wraps the entire field and label, so you shouldn’t have to worry about hiding anything else. After setting the CSS classes, we added code to check the querystring for a matching field name; if it is not null or empty, the hidden field gets populated with the value from the querystring. You can add any additional custom functionality for the textbox control here, or adjust the CSS classes.

That’s it! Just create a new form in Web Forms for Markets and it should show up like any other field.

« Prev Article
Next Article »