我已經使用下面的代碼將兩個屬性添加到窗體設計器,但它們不會顯示。字段類型與Sitecore.Form.Web.UI.Controls.CheckboxList類似,我需要它顯示相同的屬性。不幸的是,我不能進入這個代碼,模塊不會拋出任何錯誤,所以我覺得我錯過了一些簡單的東西。對於營銷人員(WFFM)的Web窗體自定義字段類型的視覺字段不顯示
public class CheckBoxListPipedField : Sitecore.Forms.Mvc.Models.Fields.CheckBoxListField
{
[VisualCategory("List")]
[VisualFieldType(typeof(Sitecore.Form.Core.Visual.ListField))]
[VisualProperty("Items:", 100)]
public ListItemCollection ListItems { get; set; }
[VisualCategory("List")]
[VisualFieldType(typeof(MultipleSelectedValueField))]
[VisualProperty("Selected Value:", 200)]
public ListItemCollection SelectedValue { get; set; }
public CheckBoxListPipedField(Item item) : base(item)
{
}
public override ControlResult GetResult()
{
var values = new List<string>();
StringBuilder stringBuilder1 = new StringBuilder();
if (this.Items != null)
{
foreach (SelectListItem selectListItem in
from item in this.Items
where item.Selected
select item)
{
values.Add(selectListItem.Value);
stringBuilder1.AppendFormat("{0}, ", selectListItem.Text);
}
}
var results = string.Join("|", values);
return new ControlResult(base.ID.ToString(), base.Title, results, stringBuilder1.ToString(0, (stringBuilder1.Length > 0 ? stringBuilder1.Length - 2 : 0)));
}
}
您是否試過從'Sitecore.Form.Web.UI.Controls.CheckboxList'繼承而不是'Sitecore.Forms.Mvc.Models.Fields.CheckBoxListField' ?. –