Web Form for Marketers MVC – Hijacked my pipeline

So finally got around to installing Sitecore Web Forms For Marketers and bang, installation process was relatively straightforward, but immediately I got a YSOD complaining that the controller could not be instantiated. In this solution we are using an IoC container to return out the controller renderings, and as such have an entry in the pipeline. WFFM MVC also ships with an entry in this pipeline that patches in Sitecore.Forms.Mvc.Pipelines.GetFormControllerRenderer before the original GetControllerRenderer that ships with Sitecore. Unfortunately in our case, not only are we are patching in our own GetControllerRenderer, but as it’s now before our pipeline entry and in inherits and fires the entry we are replaceing Sitecore have actually stopped the original controller renderer from firing.

Pipeline entries are the normal Sitecore development approach, and in true Don’t Fight The Framework style (as Sitecore have themselves) I have embraced Sitecore’s default implementation of GetController Renderer and extended it to do something subtly different, unfortunately, in this instance, it seems that Sitecore have patched in an entry that prevents future entries from firing. Below is an initial solution (that seems to work) in order to allow your additional pipeline entries to fire.

   public class GetFormControllerRenderer : GetControllerRenderer
    {
        protected override Renderer GetRenderer(Rendering rendering, GetRendererArgs args)
        {
            if (args.Rendering.RenderingItem.ID != Sitecore.Form.Core.Configuration.IDs.FormMvcInterpreterID)
            {
                return null; // this used to be base.GetRenderer(rendering, args) - now let this drop to the next in the pipeline
            }

            Tuple<string, string> controllerAndAction = this.GetControllerAndAction(rendering, args);
            if (controllerAndAction == null)
            {
                return null; // same here
            }

            string str1 = controllerAndAction.Item1;
            string str2 = controllerAndAction.Item2;
            FormControllerRenderer controllerRenderer = new FormControllerRenderer
            {
                ControllerName = str1,
                ActionName = str2
            };
            return controllerRenderer;
        }
    }

Hope this helps.

Advertisements

One thought on “Web Form for Marketers MVC – Hijacked my pipeline

  1. Hi

    WFFM team is appreciated for such a feedback.
    Proposed solution is utilized in upcomming WFFM 2.5 for Sitecore 7.5.
    Next update of WFFM 2.4 (for Sitecore 7.2) will also contain this fix.

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