From ebc198a7d47ef67f7645d33c7a25024116e2a5ea Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 8 May 2024 14:12:55 +1200 Subject: [PATCH] ENH Add MyFile to ElementContentExtension --- code/elemental/ElementContentExtension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/elemental/ElementContentExtension.php b/code/elemental/ElementContentExtension.php index 8609875..06145f7 100644 --- a/code/elemental/ElementContentExtension.php +++ b/code/elemental/ElementContentExtension.php @@ -2,6 +2,7 @@ namespace SilverStripe\FrameworkTest\Elemental\Extension; +use SilverStripe\Assets\File; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Core\Extension; use SilverStripe\Forms\FieldList; @@ -23,6 +24,7 @@ class ElementContentExtension extends Extension private static $has_one = [ 'MyPage' => SiteTree::class, + 'MyFile' => File::class, ]; public function validate(ValidationResult $result) @@ -40,7 +42,7 @@ class ElementContentExtension extends Extension public function updateCMSCompositeValidator(CompositeValidator $compositeValidator) { - $compositeValidator->addValidator(new RequiredFields(['Title', 'MyPageID'])); + $compositeValidator->addValidator(new RequiredFields(['Title', 'MyPageID', 'MyFile'])); } public function updateCMSFields(FieldList $fields)