Populate dropdown with enum values

Silverstripe Version: 4.*

I need two additional fields for general settings (TimeForClosingTab, ClosingTabOnOff). I get the fields but I don’t know how to populate the enum field correctly. The file is in app/src/extensions. What would be the correct way to define the class in singleton?

class CustomSiteConfig extends DataExtension

private static $db = [
    'TimeForClosingTab' => 'Int',
    'ClosingTabOnOff' => "Enum(array('On','Off'))"

public function updateCMSFields(FieldList $fields)
        new \SilverStripe\Forms\NumericField("TimeForClosingTab", "Time before closing new tab (s)"),
        new \SilverStripe\Forms\DropdownField('ClosingTabOnOff', 'Turn closing tab on / off',

The answer is in the yml :slight_smile:


For SiteConfig, you should get the SiteConfig object like so:

It’s already a singleton, there’s no need to create another singleton.

In this case though, assuming your CustomSiteConfig extension class in in fact only being used on SiteConfig, you should just use $this->getOwner()