我想使用GridField來查看和創建新的子頁面。父是DocumentHolder,孩子是Document。兩者都擴展SiteTree。當我點擊「添加文檔」(按網格生成的按鈕)時,填寫字段並確認表單,忽略父頁面並以root創建頁面。當我使用DataObject時,它運行良好。代碼如下所示:使用GridField添加新頁面 - 在根文件夾中創建子項
class DocumentHolder extends SiteTree
{
private static $allowed_children = array(
'Document'
);
private static $default_child = "Document";
public function getCMSFields()
{
$fields = parent::getCMSFields();
$gridField = new GridField('Documents', 'Documents', SiteTree::get('Document')->filter('ParentID', $this->ID), GridFieldConfig_RecordEditor::create());
$fields->addFieldToTab("Root.Uploads", $gridField);
return $fields;
}
}
class Document extends SiteTree
{
private static $db = array(
);
private static $has_one = array(
);
}
感謝您的幫助。
嗨艾略特,感謝答案,我也嘗試過這一點,但同樣的結果... – 2014-09-04 09:16:35