0

将 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

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

在此处输入图像描述

我尝试更改构造函数的格式。然而,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缓存。关于我在这里做错了什么有什么想法吗?

4

1 回答 1

0

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

于 2018-03-07T01:29:04.973 回答