Skip to content

Commit

Permalink
Merge pull request #339 from creative-commoners/pulls/3.0/fix-behat
Browse files Browse the repository at this point in the history
FIX Set RelatedPages gridfield to be structural
  • Loading branch information
GuySartorelli authored Jun 13, 2024
2 parents b26fdaf + 1289817 commit 8f5778a
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 8f5778a

Please sign in to comment.