Skip to content

Instantly share code, notes, and snippets.

@simple17
Created November 16, 2018 08:37
Show Gist options
  • Save simple17/fd1548a746f31d76d036c539dcd573d0 to your computer and use it in GitHub Desktop.
Save simple17/fd1548a746f31d76d036c539dcd573d0 to your computer and use it in GitHub Desktop.
[Seletion Factory] Simple select or list checkboxes property #episerver
using System.Collections.Generic;
using System.Linq;
using EPiServer.Shell.ObjectEditing;
namespace Project.Business.Selection
{
public class ResourceIconSelection : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var iconsList = new SortedDictionary<string, string>();
iconsList.Add("Link", "link");
iconsList.Add("Media", "media");
iconsList.Add("PDF", "pdf");
return iconsList
.Select(x => new SelectItem() { Text = x.Key, Value = x.Value })
.ToArray();
}
}
}
////Next declare property in your model. For select use 'SelectOne' and for list of checkboxes use 'SelectMany'.
[SelectOne(SelectionFactoryType = typeof(ResourceIconSelection))]
[Display(
Name = "Icon",
GroupName = SystemTabNames.Content,
Order = 10)]
public virtual string Icon { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment