5

I use the WFFM module for a client. The problem is just that there are wrong texts in the wizard for inserting a form:

  1. Select Insert an existing form, press next.
  2. The subtitle under Select a Form is now Copy an _existing_ form. This is misleading as the user expects to insert a form, without duplicating it.
  3. The last step in the wizard states Confirm the configuration of the _new form_. which is equally misleading.

Is there any way I can correct this?

Additions:

  • Sitecore.NET 8.1 (rev. 160519)
  • Web Forms for Marketers 8.1.rev. 160523
2
  • please specify the WFFM module version you are using. Oct 5 '16 at 8:41
  • Oh sorry, it is added :-)
    – Mads Buch
    Oct 5 '16 at 8:43
5

This is a "bug" in the WFFM module, the Sheer UI form does not set a different text for those headings. In a previous version of WFFM which did not include the "Select Existing Form" option I had added this option back in myself so it is possible to override the behaviour and set the "correct" headings.

  • Make a copy of /sitecore/shell/Applications/Modules/Web Forms for Marketers/InsertFormWizard.xml and place it in /sitecore/shell/Override folder
  • Update the CodeBeside attribute of the WizardForm element to your custom class
  • Create a new class as below to override the labels and screen text
using System.Text;
using Sitecore.Data.Items;
using Sitecore.Globalization;

namespace MySite.CMS.Custom
{
    public class InsertFormWizard : Sitecore.Forms.Shell.UI.InsertFormWizard
    {
        protected override void Localize()
        {
            base.Localize();
            // This sets the header and sub-text for the Insert Existing Form screen
            this.SelectForm["Header"] = Translate.Text("Select Existing Form");
            this.SelectForm["Text"] = Translate.Text("Select an existing form to insert");
        }

        protected override bool ActivePageChanging(string page, ref string newpage)
        {
            bool flag = base.ActivePageChanging(page, ref newpage);
            if (newpage == "ConfirmationPage" && this.InsertForm.Checked)
            {
                // This prepends details about the existing form you are selecting
                this.ChoicesLiteral.Text = RenderFormSelection() + this.ChoicesLiteral.Text;
            }
            return flag;
        }

        private string RenderFormSelection()
        {
            Item source = ExistingFormSelection();

            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append(this.RenderBeginSection("FORM"));
            stringBuilder.Append($"<p>{Translate.Text("Using existing form")}: {source.Paths.FullPath}</p>");
            stringBuilder.Append(this.RenderEndSection());
            return stringBuilder.ToString();
        }

        private Item ExistingFormSelection()
        {
            string queryString = Sitecore.Web.WebUtil.GetQueryString("la");
            Language result = Sitecore.Context.ContentLanguage;
            if (!string.IsNullOrEmpty(queryString))
                Language.TryParse(Sitecore.Web.WebUtil.GetQueryString("la"), out result);

            Item source = this.FormsRoot.Database.GetItem(this.multiTree.Selected, result);
            return source;
        }
    }
}

The header of the final translation screen is shared between all of the selection types so it is not possible to change it on a case by case basis. You could change it by adding a Dictionary entry for it though.

Using the above the screen now look like this:

Existing Form Selection

Final Confirmation Screen

It is also possible to translate all/most of the labels in the labels displayed. As @aseabridge points out, the default text is indeed embedded in a resource file within the Sitecore.WFFM DLL but labels are retrieved via a call to Sitecore.Globalization.Translate.Text(), which you will see if you follow the calls through DependenciesManager.ResourceManager.Localize(). The text is retrieved from the resource file and then it tries to locate a translation in the Domain Dictionaries (which uses dictionary fallback) otherwise it returns the default text from the resource file. The Key of the dictionary item needs to match exactly as it is in the resource file. If the dictionary items do not exist then you can create them yourself and provide the dictionary (in either domain, master or core dictionary since fallback applies), so this makes it possible to translate the labels to a different language if you wish.

5
  • Good work @jammykam. I did see some of this code but didn't realise it will look on the domain dictionaries as well. So if I were to add a new dictionary, say called 'WFFM' and add an item to it with a key of 'INSERT_FORM' and phrase of 'Copy an existing form' then the text on the first step of the Wizard would change? Pretty bad that the header is shared across sections on the final screen though and you have to override the code to fix it. Oct 5 '16 at 22:12
  • @aseabridge: I got the dictionary field name wrong :( I meant the key field needs to match, so if you created an entry with key Insert an existing form or Confirm the configuration of the new form. then you can change/translate the text. Note the dot at the end of the second phrase, it needs to match exactly.
    – jammykam
    Oct 6 '16 at 8:42
  • Oh really, so it matches on the string value not the key value - so 'Insert an existing form' instead of 'INSERT_FORM'. Thats odd, is that just how the fall-back works?. Doesn't seem like the best way to do it to me. Oct 6 '16 at 11:25
  • @aseabridge: It has nothing to do with Dictionary, but the way the WFFM implements it. First it retrieves String from the resx using the key and then passes that to Translate.Text(). If the key does not exist in the resx it returns blank, hence the reason in the Header I called Translate.Text() directly. That method has fallback, i.e. if a matching dictionary entry does not exist then it returns the Key (hence the reason it works via the resx without having dictionary entries)
    – jammykam
    Oct 6 '16 at 12:26
  • jammykam Right, I think I understand what your saying now. Oct 6 '16 at 13:17
3

This took me a little while to track down but it looks like this text for "Insert an existing form" is set in the Resources bundled inside the Sitecore.WFFM.dll so unfortunately it doesn't look like your going to be able to set this yourself from Sitecore.

enter image description here

The only solution I could think of here is to use some JQuery/Javascript to set the value of the text in the label on load of the WFFM Wizard page.

e.g something like:

$("#InsertForm").next("label").text("Copy Existing Form");
4
  • Thank you. I guess this is a bug in the WFFM module then.
    – Mads Buch
    Oct 5 '16 at 12:17
  • No problem. I'm not sure I'd say this is a bug, more that this text hasn't been deemed something that should be editable as it's not seen by end-users of the Forms - only content editors. I'd probably agree with you though that this should be editable and be in a dictionary shipped with the module so it can be edited in Sitecore. If It is and I've missed it i'll let you know. Oct 5 '16 at 12:20
  • You are completely right :-) Though, the main language of our installation is Danish, and here it is actually editable as the translation is provided in a XML file. But this would not be consistent, and a bad solution, potentially with side effects.
    – Mads Buch
    Oct 5 '16 at 12:25
  • Agreed Mads. Someone down-voted me on this and I've no idea why. My answer isn't wrong, just JammyKam has provided a solution with more insight and a way to customise this. Annoying that no comment was left about why they have done this either. Oct 6 '16 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.