亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Silverstripe 4 getCMSFields_forPopup 和 GridField

Silverstripe 4 getCMSFields_forPopup 和 GridField

PHP
拉風的咖菲貓 2023-06-18 16:29:51
多年后再次拾起它。我不能在 cms 彈出組件中使用 gridfield 嗎?這里我有 Ingredient 實體,我想將數據庫中的 Ingredients 添加到 Recipe 實體。即使是一個簡單的也不會出現。食譜.php    ...    private static $db = [        'Title' => 'Varchar',        'Description' => 'Text',    ];    private static $has_one = [];    private static $many_many = [        'Ingredients' => Ingredient::class,    ];    public function getCMSFields_forPopup()    {        $gridConfig = GridFieldConfig_RelationEditor::create()->addComponents(            new GridFieldDeleteAction('unlinkrelation')        );        $grid = GridField::create(            'Ingredients',            'Ingredients',            $this->Ingredients(),            $gridConfig,        );        $fields = FieldList::create(            TextField::create('Title'),            TextareaField::create('Description'),            $grid        );        // or maybe something like..        // $fields->addFieldToTab('Main', 'Ingredients', 'Ingredients', $grid);        return $fields;    }
查看完整描述

1 回答

?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

getCMSFields_forPopup在 Silverstripe 4 或 Silverstripe 3 中不存在。這是在 Silverstripe 2 中。


試試getCMSFields吧。


public function getCMSFields()

{

    $fields = parent::getCMSFields();


    $ingredientsFieldConfig = GridFieldConfig_RelationEditor::create();


    $ingredientsField = GridField::create(

        'Ingredients',

        'Ingredients',

        $this->Ingredients(),

        $ingredientsFieldConfig

    );


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


    return $fields;

}


查看完整回答
反對 回復 2023-06-18
  • 1 回答
  • 0 關注
  • 121 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號