2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\TextField;
|
|
|
|
use SilverStripe\ORM\Tests\DataExtensionTest\CMSFieldsChild;
|
|
|
|
|
|
|
|
/**
|
2021-10-26 05:05:11 +02:00
|
|
|
* Third level test class, testing that beforeExtendingCMSFields and afterExtendingCMSFields can be nested
|
2016-10-14 03:30:05 +02:00
|
|
|
*/
|
|
|
|
class CMSFieldsGrandChild extends CMSFieldsChild implements TestOnly
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $table_name = 'DataExtensionTest_CMSFieldsGrandChild';
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $db = [
|
2016-12-16 05:34:21 +01:00
|
|
|
'GrandchildField' => 'Varchar(255)'
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function getCMSFields()
|
|
|
|
{
|
|
|
|
$this->beforeUpdateCMSFields(
|
|
|
|
function (FieldList $fields) {
|
|
|
|
// Remove field from parent's beforeExtendingCMSFields
|
|
|
|
$fields->removeByName('ChildFieldBeforeExtension', true);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
// Adds own pre-extension field
|
|
|
|
$fields->addFieldToTab('Root.Test', new TextField('GrandchildFieldBeforeExtension'));
|
|
|
|
}
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2021-10-26 05:05:11 +02:00
|
|
|
$this->afterUpdateCMSFields(
|
|
|
|
function (FieldList $fields) {
|
|
|
|
// Remove field from parent's afterExtendingCMSFields
|
|
|
|
$fields->removeByName('ChildFieldAfterExtension', true);
|
|
|
|
|
|
|
|
// Adds own post-extension field
|
|
|
|
$fields->addFieldToTab(
|
|
|
|
'Root.Test',
|
|
|
|
new TextField('GrandchildFieldAfterExtension', 'GrandchildFieldAfterExtension')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
$fields->addFieldToTab('Root.Test', new TextField('GrandchildField'));
|
|
|
|
return $fields;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|