DataObject的ModelAdmin屏幕未打开

时间:2015-08-15 12:51:27

标签: php silverstripe data-objects modeladmin

在SilverStripe 3.1.13中,我尝试在ModelAdmin管理的DataObject之间建立一个简单的一对多关系。有一个Facility课程可以有一个FacilityCategory

我可以进入设施类别标签,但只要我输入设施标签,"主要"屏幕变为空白,然后管理员受到污染 - 没有标签会再显示内容。

我删除了以Facility和FacilityCategories开头的所有表格,并使用flush重复开发/构建。

根据为什么它不起作用,有人会对我有所了解吗?我的班级/关系有什么问题?

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'
    );
}

0 个答案:

没有答案