mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
FIX Remove any extra added tabs from SingleTabPage
This commit is contained in:
parent
58c8438ed5
commit
5bbeb77777
@ -4,6 +4,7 @@ namespace SilverStripe\FrameworkTest\Model;
|
|||||||
|
|
||||||
use Page;
|
use Page;
|
||||||
use SilverStripe\Forms\RequiredFields;
|
use SilverStripe\Forms\RequiredFields;
|
||||||
|
use SilverStripe\Forms\Tab;
|
||||||
|
|
||||||
if (!class_exists(Page::class)) {
|
if (!class_exists(Page::class)) {
|
||||||
return;
|
return;
|
||||||
@ -22,4 +23,22 @@ class SingleTabPage extends Page
|
|||||||
'Content'
|
'Content'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCMSFields()
|
||||||
|
{
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
|
// Page may will extend CWP BasePage if running in a kitchen-sink context,
|
||||||
|
// so removing any extra tabs added - this class is for a "single tab" test
|
||||||
|
$tabFieldNames = [];
|
||||||
|
foreach ($fields->flattenFields() as $field) {
|
||||||
|
$fieldName = $field->getName();
|
||||||
|
if (is_a($field, Tab::class) && $fieldName !== 'Main') {
|
||||||
|
$tabFieldNames[] = $fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($tabFieldNames as $tabFieldName) {
|
||||||
|
$fields->removeByName($tabFieldName);
|
||||||
|
}
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user