You can write your own rule in Sitecore WFFM.
public class AutoPopulateCheckBoxListOption<T> : RuleAction<T> where T : ConditionalRuleContext
{
public override void Apply(T ruleContext)
{
Item FieldItem = null;
if (ruleContext.Control is IResult)
{
FieldItem = GetItemFromDatabase(Sitecore.Context.Database.Name, ((IResult)ruleContext.Control).FieldID);
if (FieldItem != null)
{
var cblType = (Sitecore.Form.Web.UI.Controls.CheckboxList)(IResult)ruleContext.Control;
string fieldValues = "A::B::C::D";
if (!string.IsNullOrWhiteSpace(fieldValues))
{
string[] values = fieldValues.Split(new[] { "::" }, StringSplitOptions.None);
foreach (string c in values)
{
cblType.Items.FindByValue(c).Selected = true;
}
}
}
return;
}
}
public Item GetItemFromDatabase(string database, string FormUri)
{
Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase(database);
return db.GetItem(FormUri);
}
}
No comments:
Post a Comment