The Introduction field of the WFFM form is rendered using a UI control. I think the easiest way to achieve your token replacement solution is to modify this UI control overriding its OnLoad() method to add your token replacement logic.
The main Form control is defined in the SitecoreSimpleFormAscx.ascx control (\sitecore modules\Web\Web Forms for Marketers\Control\SitecoreSimpleFormAscx.ascx
) and here you'll find the Form Introduction control that is responsible to render the form introduction (<wfm:FormIntroduction ID="intro" runat="server"/>
).
Create a CustomFormIntroduction control following the implementation of the original FormIntroduction control (see code below), add your logic to replace the tokens in the OnLoad method, and then replace the existing default FormIntroduction control with your custom control (<customwfm:CustomFormIntroduction ID="intro" runat="server"/>
).
CustomFormIntroduction class code:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sitecore.Data.Items;
using Sitecore.Form.Web.UI.Controls;
using Sitecore.Xml.Xsl;
namespace Custom.WFFM.Controls
{
[ToolboxData("<div runat=\"server\"></div>")]
public class CustomFormIntroduction : FormText
{
public CustomFormIntroduction()
: base((Item)null, Sitecore.Form.Core.Configuration.FieldIDs.FormIntroductionID, HtmlTextWriterTag.Div)
{
}
public CustomFormIntroduction(Item item)
: base(item, Sitecore.Form.Core.Configuration.FieldIDs.FormIntroductionID, HtmlTextWriterTag.Div)
{
}
protected override void OnLoad(EventArgs e)
{
this.Attributes["class"] = "scfIntroBorder";
if (!(this.Item.Fields[Sitecore.Form.Core.Configuration.FieldIDs.ShowFormIntroID].Value == "1"))
return;
if (this.Item == null)
return;
Sitecore.Web.UI.WebControls.FieldRenderer fieldRenderer = new Sitecore.Web.UI.WebControls.FieldRenderer();
fieldRenderer.Item = this.Item;
fieldRenderer.FieldName = this.Item.Fields[this.Field].Name;
fieldRenderer.Parameters = this.Parameters ?? string.Empty;
fieldRenderer.DisableWebEditing = this.DisableWebEditing;
RenderFieldResult renderFieldResult = fieldRenderer.RenderField();
this.Controls.Add((Control)new Literal()
{
Text = renderFieldResult.ToString() // HERE ADD YOUR LOGIC TO REPLACE THE TOKEN
});
}
}
}