I am trying to create a dropdown list (ss4.2) but I am missing something and I am not sure what. I have had success with other methods except the one I need. Would someone be able to help me figure out what I have missed?
<?php
namespace SilverStripe\Gallery;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\DropdownField;
use SilverStripe\ORM\DBEnum;
class Album extends DataObject {
private static $db = [
'AlbumType' => 'Enum(array("Type1","type2","Type3"), "Type1")',
];
private static $table_name = 'AlbumCoverPhoto';
public function getCMSFields() {
$fields = FieldList::create(
DropdownField::create('AlbumType',
'Album type',
singleton('Album')->dbObject('AlbumType')->enumValues())
);
return $fields;
}
}
Thanks. Lyn