您应该可以通过创建 FieldID 属性来访问控件中的字段 ID。这应该等同于定义字段的模板字段项的 ID。因此,您可以通过
var fieldItem = Sitecore.Context.ContentDatabase.GetItem(this.FieldID);
var fieldName = fieldItem.Name;
Sitecore 可以在您的控件上设置的属性的完整列表可以在 中找到Sitecore.Shell.Applications.ContentEditor.EditorFormatter.SetProperties
。
ReflectionUtil.SetProperty(editor, "ID", field.ControlID);
ReflectionUtil.SetProperty(editor, "ItemID", field.ItemField.Item.ID.ToString());
ReflectionUtil.SetProperty(editor, "ItemVersion", field.ItemField.Item.Version.ToString());
ReflectionUtil.SetProperty(editor, "ItemLanguage", field.ItemField.Item.Language.ToString());
ReflectionUtil.SetProperty(editor, "FieldID", field.ItemField.ID.ToString());
ReflectionUtil.SetProperty(editor, "Source", field.ItemField.Source);
ReflectionUtil.SetProperty(editor, "ReadOnly", readOnly);
ReflectionUtil.SetProperty(editor, "Disabled", readOnly);