Skip to content

Commit 1289817

Browse files
committed
FIX Set RelatedPages gridfield to be structural
1 parent b26fdaf commit 1289817

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

src/PageTypes/BasePage.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
1818
use TractorCow\Fluent\Model\Locale;
1919
use TractorCow\Fluent\State\FluentState;
20+
use SilverStripe\Forms\FormField;
2021

2122
/**
2223
* `BasePage` is a foundation page class which can be used for constructing your own page types. By default it is
@@ -127,15 +128,22 @@ public function getCMSFields()
127128
'Root.RelatedPages',
128129
_t(__CLASS__ . '.RelatedPages', 'Related pages')
129130
);
130-
$fields->addFieldToTab(
131-
'Root.RelatedPages',
132-
GridField::create(
133-
'RelatedPages',
134-
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
135-
$this->RelatedPagesThrough(),
136-
$components
137-
)
138-
);
131+
$args = [
132+
'RelatedPages',
133+
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
134+
$this->RelatedPagesThrough(),
135+
$components
136+
];
137+
$gridField = GridField::create(...$args);
138+
// If GridField has been replaced by Injector, use that
139+
// Otherwise use anonymous class so that versioned-admin behat tests pass
140+
// when running in kitchen-sink
141+
if (get_class($gridField) === GridField::class) {
142+
$gridField = new class (...$args) extends GridField {
143+
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL;
144+
};
145+
}
146+
$fields->addFieldToTab('Root.RelatedPages', $gridField);
139147

140148
// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
141149
$hasMany = $this->hasMany();

0 commit comments

Comments
 (0)