Skip to content

Commit

Permalink
FIX Set RelatedPages gridfield to be structural
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 12, 2024
1 parent b26fdaf commit 1289817
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/PageTypes/BasePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use TractorCow\Fluent\Model\Locale;
use TractorCow\Fluent\State\FluentState;
use SilverStripe\Forms\FormField;

/**
* `BasePage` is a foundation page class which can be used for constructing your own page types. By default it is
Expand Down Expand Up @@ -127,15 +128,22 @@ public function getCMSFields()
'Root.RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages')
);
$fields->addFieldToTab(
'Root.RelatedPages',
GridField::create(
'RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
$this->RelatedPagesThrough(),
$components
)
);
$args = [
'RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
$this->RelatedPagesThrough(),
$components
];
$gridField = GridField::create(...$args);
// If GridField has been replaced by Injector, use that
// Otherwise use anonymous class so that versioned-admin behat tests pass
// when running in kitchen-sink
if (get_class($gridField) === GridField::class) {
$gridField = new class (...$args) extends GridField {
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL;
};
}
$fields->addFieldToTab('Root.RelatedPages', $gridField);

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

0 comments on commit 1289817

Please sign in to comment.