sitecoresitecore-mvcweb-forms-for-marketerssitecore8.1

Custom MVC Views in WFFM


I am in the process of fitting Sitecore Web Forms for Marketers to a solution. For that to work I need 3 things:

  1. The ability to inject JavaScript from a rul
  2. Rewriting all generated code to use Foundation (instead of Bootstrap)
  3. Be able to read the submittet data of a "changed" form. Ie. a form where there is injected extra field through JavaScript.

My initial questions for this is to the second point: How do I write these views?

I have followed this article: http://www.hhogdev.com/blog/2015/september/customizing%20wffm%20in%20sitecore%208.aspx but unfortunately He does not elaborate on how to generate proper names/ids for fields and the form.

Can anybody point me in the right direction for that?


Solution

  • The blog post you linked to was written based on Sitecore 8.0, and although the module is the same the implementation of WFFM has since changed (unfortunately for the worse IMO).

    We are currently using WFFM with Foundation, so it is possible to have them both working together but there are a few things you have to do.

    I config disable Bootstrap CSS, this will mean Bootstrap markup but without the CSS files being included. I suggest you style around the given settings as much as possible to save future upgrade issues:

    <settings>
      <setting name="WFM.EnableBootstrapCssRendering">
        <patch:attribute name="value">false</patch:attribute>
      </setting>
    </settings>
    

    If you need to edit the markup then the default views for the form field markup files can be found under: Website\Views\Form and the EditorTemplates folder under that. Here's the kicker. In versions earlier than 8.0 update-5 the markup did not use the Bootstrap helper and therefore the markup was all present. The latest implementation hides this all away and therefore harder to edit in my opinion.

    If you struggle with the Bootstrap markup then take a look at the view files from WFFM 8.0 update-5 or earlier. The markup is much more obvious and you should be able to (essentially) port these over to Sitecore 8.1 and then amend the markup as required (although we have found added the correct surrounding foundation DIV's were enough)

    I have no idea what you mean by point 1, but for point 3, you can't. WFFM only works on the fields that you create on the back end, any new fields you create with JS will get lost. If you need to do something clever then use a hidden field (this requires adding a custom field type unfortunately) and then populate this hidden field with the data that you need passed back to the server.