Søren Mastrup
01/17/2025, 8:33 AMc#
public class CountrySelect : FieldType
{
private static readonly List<Setting> SettingsList = new List<Setting>
{
new KeyModeSettingAttribute("Select how value will be submitted")
};
public CountrySelect()
{
// ...
// Field is defined here (Id (guid), FieldTypeViewName...
// ...
}
public override Dictionary<string, Setting> Settings() => SettingsList.ToDictionary(l => l.Alias, l => l);
}
The KeyModeSettingAttribute
looked like this:
c#
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class KeyModeSettingAttribute : Setting
{
public const string FieldAlias = "keyMode";
private static readonly Dictionary<string, KeyMode> PrevaluesList = new Dictionary<string, KeyMode>
{
{ "key", KeyMode.Key },
{ "title", KeyMode.Title },
{ "english title", KeyMode.EnglishTitle }
};
public KeyModeSettingAttribute(string description)
: base("Key Mode")
{
this.Description = description;
this.View = "dropdownlist";
this.Alias = FieldAlias;
this.PreValues = string.Join(",", PrevaluesList.Keys);
}
}
In v13 I have tried to update the code to this:
c#
public class CountrySelect : FieldType
{
public CountrySelect()
{
// ...
// Field is defined here (Id (guid), FieldTypeViewName...
// ...
}
[Setting("Key Mode", Alias = "keyMode", Description = "Select how value will be submitted", View = "dropdownlist", PreValues = "key,title,english title")]
public string KeyMode { get; set; }
}
Søren Mastrup
01/22/2025, 7:25 AM