API Reference: CheckboxAttribute Class

The CheckboxAttribute can be applied to content model properties. The attribute specifies that a checkbox editor should be rendered for this property in the back office.

If CheckboxAttribute is not specified on a content model property, and no other editor type attributes have been set, the default property editor will be rendered for the type in the back office. For boolean property types, the checkbox editor is selected by default.

Usage

Decorate the content model property with the CheckboxAttribute. See the Checkbox Editor page for more information on how to configure the checkbox editor. Checkbox editors can be used for all value type properties, not only boolean.

Properties of type boolean will render a checkbox editor by default. If no additional configuration is required, it is not necessary to set the CheckboxAttribute for boolean property types.

Example

The following example renders different checkbox editors for properties of aContentPage content model.

[Page]
public class ContentPage: IContentType
{
    // Render checkbox for integer property.
    [Checkbox(CheckedValue = 100, UncheckedValue = 10)]
    public int IntegerValue { get; set; }

    // Render checkbox for string property.
    [Checkbox(CheckedValue = "enabled", UncheckedValue = "disabled", Label = "Enable feature X")]
    public string SwitchEnabled { get; set; }

    // CheckboxAttribute is only used to set the checkbox label; it already is the default editor for boolean properties.
    [Checkbox(Label = "Hide in navigation")]
    public bool HideInNavigation { get; set; }
}