Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
[EditorDescriptor(EditorDescriptorType = typeof(EnumEditorDescriptor<SomeEnum>))]
then
public class EnumEditorDescriptor<TEnum> : EditorDescriptor where TEnum : struct, IComparable, IConvertible, IFormattable
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
SelectionFactoryType = typeof(EnumSelectionFactory<TEnum>);
ClientEditingClass = "epi-cms/contentediting/editors/SelectionEditor";
base.ModifyMetadata(metadata, attributes);
}
}
public class EnumSelectionFactory<TEnum> : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var values = Enum.GetValues(typeof(TEnum))
.OfType<object>()
.Select(x=> new SelectItem { Text = "HERE-EXTRACT-TEXT-FROM-LOCALIZATION-SERVICE", Value = x});
return values;
}
Maybe I'm misunderstanding this but shouldn't it be possible to put this in a language XML resource file in //languages/language node:
<property>
<enum>
<textfieldsize>
<small>Small - Single line</small>
<standard>Standard - Single line</standard>
<large>Large - Single line</large>
</textfieldsize>
</enum>
</property>
I have an enum property in the block model.
public enum TextFieldSize { Small, Standard, Large }
[BackingType(typeof(PropertyNumber))]))]
[EditorDescriptor(EditorDescriptorType = typeof(EnumSelector
[Display(
Name = "Field size",
Description = "Determines width of field displayed",
GroupName = SystemTabNames.Content,
Order = 50)]
public virtual TextFieldSize FieldSize { get; set; }
public override void SetDefaultValues(ContentType contentType)
{
base.SetDefaultValues(contentType);
FieldSize = TextFieldSize.Standard;
}
In the CMS editor, it displays the dropdown with the list of enums (Small, Standard, Large).
But I want to have display name for each. That is, instead of 'Small' I want to display as 'Small - Single Line'.
Small - Small - Single Line
Standard - Standard - Single Line
Large - Large - Multi line
I have change the enum property to
public enum TextFieldSize { [Display(Name = "Small - Single line")]Small, [Display(Name = "Standard - Single line")]Standard, [Display(Name = "Large - Multi line")]Large }
but it's does show any display names.