【发布时间】:2018-08-23 02:22:00
【问题描述】:
我正在尝试创建一个下拉列表 (ss4.2),但我遗漏了一些东西,我不确定是什么。除了我需要的方法之外,我已经用其他方法取得了成功。有人能帮我弄清楚我错过了什么吗?
<?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;
}
}
谢谢。 林恩
【问题讨论】:
标签: php silverstripe silverstripe-4