Select Fields

Last Updated: 2019-02-10

If you want to read more about the basic fields included in Piranha, please refer to Standard Fields.

Select Fields are an easy way to add dropdown fields based on Enums to your Content Types. This feature is build into Piranha but still requires some extra initialization to work.

Registering The Field

For Select Fields to function they must be registered for each Enum being used. This is because each implementation of the generic type SelectField<> needs to have it's own Serializer registered.


An Example

Let's for example say we have a HeroRegion in our application that presents a banner at the top of the page. In this Hero we can set a Background Image, but depending on the image we want the text to be Dark or Light to provide good contrast. This is a perfect use case for adding a Select Field.


public enum HeroStyle


public class HeroRegion
public ImageField BackgroundImage { get; set; }

public StringField Title { get; set; }

public HtmlField Body { get; set; }

public SelectField<HeroStyle> Style { get; set; }