DataObject 的 ModelAdmin 屏幕未打开

ModelAdmin screen for DataObject not opening

在 SilverStripe 3.1.13 中,我试图在 ModelAdmin 管理的数据对象之间建立简单的一对多关系。有一个Facilityclass可以有一个offFacilityCategory.

我可以进入 Facility Category 选项卡,但是我一进入 Facility 选项卡,"main" 屏幕就变成空白,管理员从此被污染- 不再有标签显示内容。

我删除了所有以 Facility 和 FacilityCategories 开头的表,并用 flush 重复 dev/build。

有人能告诉我为什么它不起作用吗?我的 classes/relations 有什么问题?

Facility.php

class Facility extends DataObject {
    private static $db = array(
        'Title' => 'Varchar',
    );

    private static $has_one = array(
        'Category' => 'FacilityCategory'
    );

    public static $summary_fields = array(
        'Title', 'Category'
    );



    public function getCMSFields(){
        $fields = FieldList::create(
            TextField::create('Title'),
            DropdownField::create('FacilityCategoryID', 'Category')
                ->setSource(FacilityCategory::get()->map('ID', 'Title'))
                ->setEmptyString('-- select a category --')
        );
        return $fields;
    }
}

class FacilityAdmin extends ModelAdmin {
    private static $menu_title = 'Facilities';
    private static $url_segment = 'facilities';
    private static $managed_models = array(
        'Facility'
    );
}

FacilityCategory.php

class FacilityCategory extends DataObject {
    private static $db = array(
      'Title' => 'Varchar'
    );

    private static $has_many = array(
      'Facilities' => 'Facility'
    );

    public function getCMSFields(){
        $fields = FieldList::create(
            TextField::create('Title')
        );
        return $fields;
    }
}

class FacilityCategoryAdmin extends ModelAdmin {
    private static $menu_title = 'Facility Categories';
    private static $url_segment = 'facility-categories';
    private static $managed_models = array(
        'FacilityCategory'
    );
}

可能是在您的 $summary_fields(应该是私有的)中,您列出了相关的类别对象而不是类别对象上的特定字段,因此:

private static $summary_fields = array(
  'Title', 
  'Category.Title'
);