4

I'm currently setting up some Save Actions and 1 of them is 'Send Email Action'. In the sent mail, the value of a checkbox field is always 'True' or 'False'.

Since it is a multilingual site, this needs to be translated properly. Where can I configure this?

1
  • If my understanding is correct, you are going to translate the captured value into the email.
    – Abhi
    Nov 29, 2017 at 10:52

2 Answers 2

3

You can override Checkbox class and add Adapter attribute. It's there in WFFM already. I have no idea why it's not used by default.

namespace WffmCustomization
{
    [Adapter(typeof(CheckboxAdapter))]
    public class Checkbox : Sitecore.Form.Web.UI.Controls.Checkbox
    {
    }
}

Set Assembly and Class fields of /sitecore/system/Modules/Web Forms for Marketers/Settings/Field Types/Simple Types/Checkbox item to your Checkbox class:

enter image description here

Then add entries with Key set to Selected and Not Selected (camel case - important) in the language you need.

enter image description here

2

To get the translated value in the mail body, we added a processor in the processMessage pipeline.

<processMessage patch:source="Sitecore.Forms.config">
  <processor type="WFFM.Customization.SaveActions.EmailExt, WFFM.Customization" method="TranslateValues"/> 
</processMessage>
public class EmailExt
{
    public EmailExt()
    { }

    public void TranslateValues(ProcessMessageArgs args)
    {
        // logic to translate
        foreach (AdaptedControlResult result in args.Fields)
        {

        }
    }
} 
1
  • We tested it. 1) It’s not possible to overwrite the value of the results you are looping (of type AdaptedControlResult). A workaround for this would be to set it by reflection using: typeof(AdaptedControlResult).GetProperty("Value", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).SetValue(result, value); 2) We're sending 2 mails when saving the form. The first mail still contained true or false. It was only the second mail that contained the translated values, so something fishy with the events.
    – Koen Heye
    Dec 4, 2017 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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