I have
private static $db = [
'FooterSection' => 'Enum("Navigate, About, Legal")'
];
and
$fields->addFieldsToTab('Root.Main', [
DropdownField::create('FooterSection', 'Footer section', [
'Navigate' => 'Navigate',
'About' => 'About',
'Legal' => 'Legal'
])->setEmptyString('Not displayed in footer')
], 'Metadata');
When i create a new page, "Navigate" is always selected, instead of "Not displayed in footer"
Adding:
private static $defaults = [
'FooterSection' => 0
];
Fixes it for me
SilverStripe version?
4
@zanderwar after this fix, you can use null as a second arg in your $db spec, and it'll correctly set an empty default.
private static $db = [
'FooterSection' => 'Enum("Navigate, About, Legal", null)'
];
Added pr for postgres fix at https://github.com/silverstripe/silverstripe-postgresql/pull/78 too
Most helpful comment