2021-02-10 01:56:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\FrameworkTest\Model;
|
|
|
|
|
2021-02-25 02:44:26 +01:00
|
|
|
use Page;
|
2021-02-10 01:56:21 +01:00
|
|
|
use SilverStripe\Forms\RequiredFields;
|
2024-06-13 02:18:39 +02:00
|
|
|
use SilverStripe\Forms\Tab;
|
2021-02-10 01:56:21 +01:00
|
|
|
|
2021-02-25 02:44:26 +01:00
|
|
|
if (!class_exists(Page::class)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-10 01:56:21 +01:00
|
|
|
/**
|
|
|
|
* This class is specifically for the silverstripe/admin behat test multitab-validation.feature
|
|
|
|
*/
|
2021-02-25 02:44:26 +01:00
|
|
|
class SingleTabPage extends Page
|
2021-02-10 01:56:21 +01:00
|
|
|
{
|
2021-02-25 11:51:25 +01:00
|
|
|
private static $table_name = 'SingleTabPage';
|
|
|
|
|
2021-02-10 01:56:21 +01:00
|
|
|
public function getCMSValidator()
|
|
|
|
{
|
|
|
|
return new RequiredFields([
|
|
|
|
'Content'
|
|
|
|
]);
|
|
|
|
}
|
2024-06-13 02:18:39 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2021-02-10 01:56:21 +01:00
|
|
|
}
|