我是否可以在同一数据对象中命名的管理页面中有2个网格域组件 - 例如
logger.debug()
答案 0 :(得分:0)
has_one
课程中相应的ImageWithHTML
关系,请参阅https://docs.silverstripe.org/en/4/developer_guides/model/relations/#has-many
所以你的代码应该是这样的:
class MainLandingPage_au extends Page
{
private static $has_many = [
'ImagesWithHtml' => `\Namespace\Of\ImageWithHtml.Foo`,
'ImagesWithHtml2' => `\Namespace\Of\ImageWithHtml.Bar`
];
在另一边
class ImageWithHtml extends DataObject
{
private static $has_one = [
'Foo' => MainLandingPage_au::class,
'Bar' => MainLandingPage_au::class
];
答案 1 :(得分:0)
是可以使用2个网格域,这适用于适当的个人关系
class MainLandingPage_au extends Page
{
private static $has_many = [
'ImagesWithHtml' => ImageWithHtml::class . '.AuMainLandingPage',
'ImagesWithHtml2' => ImageWithHtml::class . '.AuMainLandingPage2'
];
// ...
// Gridfields as in posted question
// ... etc
另一方
class ImageWithHtml extends DataObject
{
private static $has_one = [
'AuMainLandingPage' => AuMainLandingPage::class . '.ImagesWithHtml',
'AuMainLandingPage2' => AuMainLandingPage::class . '.ImagesWithHtml2'
];