Merge pull request #172 from creative-commoners/pulls/1/non-inline-behat

ENH Make ElementalContentExtension MyPage a required field
This commit is contained in:
Guy Sartorelli 2024-05-06 14:41:28 +12:00 committed by GitHub
commit d12463ae60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ use SilverStripe\Registry\RegistryPage;
use SilverStripe\Security\DefaultAdminService;
use SilverStripe\Security\Member;
if (!class_exists(RegistryPage::class)) {
if (class_exists(RegistryPage::class)) {
class TestRegistryPage extends RegistryPage
{
public function requireDefaultRecords()

View File

@ -2,6 +2,7 @@
namespace SilverStripe\FrameworkTest\Elemental\Extension;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\ValidationResult;
@ -20,6 +21,10 @@ class ElementContentExtension extends Extension
'MyInt' => 'Int',
];
private static $has_one = [
'MyPage' => SiteTree::class,
];
public function validate(ValidationResult $result)
{
if ($this->owner->Title == 'x') {
@ -35,7 +40,7 @@ class ElementContentExtension extends Extension
public function updateCMSCompositeValidator(CompositeValidator $compositeValidator)
{
$compositeValidator->addValidator(new RequiredFields(['Title']));
$compositeValidator->addValidator(new RequiredFields(['Title', 'MyPageID']));
}
public function updateCMSFields(FieldList $fields)