[Fixed] Sitecore WFFM : Creates a duplicate field section upon submission when exceeded to 10 sections.

Posted on Updated on

As explained in Stackoverflow > Sitecore WFFM : Creates a duplicate field section upon submission.

I eventually raised the issue to Sitecore, and after quite while they provided a Sitecore bug fix for my issue. I’ve tested the patch and it’s working now.

Thank you for filling up the form

Moreover, the following patch should to be implemented:

  1. Put the attached library into the bin folder. Download here.  (Applicable only for v.8.0)
  2. In the App_Config/Include/Sitecore.Forms.MVC.config file, replace the following line:

From:

<processor patch:before=”processor[@type=’Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc’]”
type=”Sitecore.Forms.Mvc.Pipelines.AddCustomMetadataProvider, Sitecore.Forms.Mvc” />

To:

<processor patch:before=”processor[@type=’Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc’]”
type=”Sitecore.Support.Forms.Mvc.Pipelines.AddCustomMetadataProvider, Sitecore.Support.434449” />

 

Disassembling the Sitecore.Support.434449.dll to understand the root cause a little further

#1. Override the CreateModel of SectionModelBinder


namespace Sitecore.Support.Forms.Mvc.Controllers.ModelBinders
{
public class SectionModelBinder : Sitecore.Forms.Mvc.Controllers.ModelBinders.SectionModelBinder
{
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
IHasModelFactory hasModelFactory = controllerContext.Controller as IHasModelFactory;
FormModel formModel = (hasModelFactory != null) ? hasModelFactory.ModelFactory.GetModel() : null;
if (formModel == null)
{
return base.CreateModel(controllerContext, bindingContext, modelType);
}
int index = int.Parse(bindingContext.ModelName.Substring(bindingContext.ModelName.IndexOf('[') + 1, bindingContext.ModelName.IndexOf(']') - bindingContext.ModelName.IndexOf('[') - 1));
return formModel.Sections[index];
}
}
} 

#2. Modify the  AddCustomMetadataProvider class > virtual void process

namespace Sitecore.Support.Forms.Mvc.Pipelines
{
internal class AddCustomMetadataProvider
{
[UsedImplicitly]
public virtual void Process(PipelineArgs args)
{
ModelMetadataProviders.Current = new ModelTypeMetadataProvider();
ModelBinders.Binders.Add(typeof(SectionModel), new Sitecore.Support.Forms.Mvc.Controllers.ModelBinders.SectionModelBinder());
ModelBinders.Binders.Add(typeof(FieldModel), new FieldModelBinder());
}
}
}

 

Edited: 08.03.2016

Sitecore.Support.434449.dll can be dowloaded here.

 

Edited: 08.04.2016

In Sitecore version 8.1

The following patch should to be implemented:

  1. Put the attached library into the bin folder. Download here. (Applicable only for v.8.1)
  2. In the App_Config/Include/Sitecore.Forms.MVC.config file, replace the following line:

From:

<processor patch:before=”processor[@type=’Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc’]”
type=”Sitecore.Forms.Mvc.Pipelines.AddCustomMetadataProvider, Sitecore.Forms.Mvc” />

To:

<processor patch:before=”processor[@type=’Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc’]”
type=”Sitecore.Support.Forms.Mvc.Pipelines.AddCustomMetadataProvider, Sitecore.Support.434449.81” />

Advertisements

2 thoughts on “[Fixed] Sitecore WFFM : Creates a duplicate field section upon submission when exceeded to 10 sections.

    Alan said:
    July 20, 2016 at 7:12 pm

    Do we know if 8.1 U3 has resolved this issue now?

    Like

      Marvin Glenn Lacuna responded:
      July 20, 2016 at 10:29 pm

      Hi Alan,

      Unfortunately, since the issue was logged after the v.8.1 U3 release date, thus, the patch was not included. But I supposed that they would include it on the upcoming releases.

      Cheers,
      Marvin

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s