07 December 2015

Incorrect data is saved for list fields in Sitecore WFFM MVC

When you use Sitecore WebForms for Marketers MVC, then chances are you run into the problem that the chosen values for list fields are saved incorrectly or not at all when submitting the form. For instance, when I submitted a form, no data was saved for drop lists and System.String[] was saved as value for a date picker. At the time of writing, this applies to WFFM 2.4+.

The solution is two-folded. First of all, there is a known issue described on the Sitecore Knowledge Base. The remedy is to download the support dll and to make changes to some WFFM files and items. Make sure you pick the right Sitecore version.

But even after applying that fix, I still ran into the same issue. It turned out that Sitecore WFFM MVC relies on the default dependency resolver and that I've set that resolver according to the Autofac documentation as follows:

var builder = new ContainerBuilder();

// Register your types
// ...

var container = builder.Build();

// Set the resolver to Autofac
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

WFFM expects to find the Sitecore dependency resolver there, but finds Autofac instead. A resolver that doesn't know anything about the WFFM types. To overcome that issue, you must register the WFFM types yourself.

// Sitecore WFFM
builder.RegisterType<Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders.DefaultFieldValueBinder>().AsSelf();
builder.RegisterType<Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders.CaptchaFieldBinder>().AsSelf();
builder.RegisterType<Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders.CheckboxFieldValueBinder>().AsSelf();
builder.RegisterType<Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders.DatePickerFieldValueBinder>().AsSelf();
builder.RegisterType<Sitecore.Forms.Mvc.Controllers.ModelBinders.FieldBinders.ListFieldValueBinder>().AsSelf();

After that, data from list fields should be saved properly again!

02 December 2015

Multilingual e-mail and date selector in Sitecore Web Forms for Marketers (WFFM)

Multilingual e-mails

Sitecore WFFM does not support multilingual e-mails out of the box. In other words, the e-mail sent will always be in the default language. To enable multilingual e-mails, open /sitecore/templates/Web Forms for Marketers/Form/Submit/Save Actions, uncheck the “Shared” checkbox and save.

If you already have existing forms, then you will need to re-add all the save actions in each language for all forms. You must do this in a specific way: use the Form Designer inside Sitecore Client and only change the language in the form designer.




Multilingual date selector

When using a field of type 'Date' (or 'DateSelector'), you’ll get 3 dropdowns, with a label on top of it. These labels are in English.


To add translations for these labels, do the following:
  1. Go to /sitecore/system/Dictionary
  2. Create a new dictionary folder, e.g. WFM, just to keep things organized.
  3. Create a dictionary entry for each label
    1. Use the following rule for the Key value: "{0}WFM: {1}" (without the quotes)
      where {1} is your key (i.e. 'Day' - 'Month' - 'Year')
      and {0} is the first letter of the key in uppercase.
    2. Enter a Phrase in each language