Bug: Web Forms For Marketers Adds a Duplicate Tag

Vasiliy Fomichev

In Errors, Sitecore Fix Posted

Sitecore Web Forms for Marketers (WFFM) module MVC rendering creates two duplicate form closing tags, which may result in JavaScript errors with walking the DOM. The issue was found in WFFM Update 4 running on Sitecore 8 Update 5, however, other versions may be affected as well.

 

Duplicate Web Forms For Marketers </form> Tag

Recently I spent a lot of time working with Web Forms for Marketers module using MVC and ran into a few issues that I haven’t seen posts about, one of which was that the MVC rendering that the module uses adds a duplicate form closing tag right after the first one (more on other issues in future posts).

 

 </form></form>

 

Developers would definitely not lose sleep over this one. In fact you may have already been running the module with this bug without any issues! However, if you are a JavaScript enthusiast and try to do some tricky things with the DOM, you might run into some errors, in which case – read on!

 

How to Fix The Duplicate Form Closing tag in WFFM MVC Rendering

The fix issue was thankfully very straight-forward:

  1. Open the \Website\Views\Form\EditorTemplates\FormModel.cshtml
  2. Scroll to the end of the file and remove the following code:

 

 @{Html.EndForm();} 

 

It seems like someone forgot that

 

@using (Html.BeginRouteFom...)
{
...
}

already adds a closing tag 😉 So, here you go – short and sweet this time 🙂

Hopefully, this post will save many developers hours or days of troubleshooting, and please share this article, as many more developers will thank you. Also remember to comment if this worked for you, and give back by blogging, tweeting, and posting on Sitecore forums about any bugs and fixes you find yourself!

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: