Silverstripe 4 - TreeDropdownField未在CMS中显示

时间:2018-03-06 04:19:52

标签: silverstripe-4

将3.5站点升级到4.x.我有以下扩展名:

class BrandExtension extends DataExtension {

    private static $has_one = array(
        "BrandPage" => BrandPage::class
    );                

    public function updateCMSFields(FieldList $fields) {
        parent::updateCMSFields($fields);

        $mic = new TreeDropdownField("BrandPageID", "Select portfolio page to link to", SiteTree::class);

        $fields->addFieldToTab('Root.Main', $mic, 'Content');

    }

}

这是命名空间,所以我更新了config.yml包含:

Vendor\Project\MicrositePage:
  extensions:
    - Vendor\Project\BrandExtension

在开发/构建之后,该字段似乎想要显示,但它只显示标签。

enter image description here

我尝试更改构造函数的格式。 4.0文档表明以上是正确的格式。而改变构造函数并没有做任何事情。

$mic = TreeDropdownField::create("BrandPageID", "Select portfolio page to link to", SiteTree::class);

检查页面显示我正在注入某些东西。

<div class="TreeDropdownField treedropdown single searchable searchable" id="Form_EditForm_BrandPageID" data-schema="{&quot;name&quot;:&quot;BrandPageID&quot;,&quot;id&quot;:&quot;Form_EditForm_BrandPageID&quot;,&quot;type&quot;:&quot;text&quot;,&quot;schemaType&quot;:&quot;SingleSelect&quot;,&quot;component&quot;:&quot;TreeDropdownField&quot;,&quot;holderId&quot;:&quot;Form_EditForm_BrandPageID_Holder&quot;,&quot;title&quot;:&quot;Select portfolio page to link to&quot;,&quot;source&quot;:null,&quot;extraClass&quot;:&quot;treedropdown single searchable&quot;,&quot;description&quot;:null,&quot;rightTitle&quot;:null,&quot;leftTitle&quot;:null,&quot;readOnly&quot;:false,&quot;disabled&quot;:false,&quot;customValidationMessage&quot;:&quot;&quot;,&quot;validation&quot;:[],&quot;attributes&quot;:[],&quot;autoFocus&quot;:false,&quot;data&quot;:{&quot;urlTree&quot;:&quot;admin\/pages\/edit\/EditForm\/153\/field\/BrandPageID\/tree&quot;,&quot;showSearch&quot;:true,&quot;emptyString&quot;:&quot;(Choose Page)&quot;,&quot;hasEmptyDefault&quot;:false,&quot;multiple&quot;:false}}" data-state="{&quot;name&quot;:&quot;BrandPageID&quot;,&quot;id&quot;:&quot;Form_EditForm_BrandPageID&quot;,&quot;value&quot;:0,&quot;message&quot;:null,&quot;data&quot;:{&quot;cacheKey&quot;:&quot;2018-03-06 03:43:41&quot;,&quot;showSelectedPath&quot;:false}}">
<input id="Form_EditForm_BrandPageID" type="hidden" name="BrandPageID" value="0">

完成多个开发构建。试图冲洗CMS。甚至在/ tmp下删除了SS缓存。对我在这里做错了什么的想法?

1 个答案:

答案 0 :(得分:0)

我发现退出CMS并再次返回会导致显示该字段。虽然看起来确实有点敏感。有几次我刷新了我的CMS页面,它已经在加载时消失了。