From 10b546ad0ef5bb491189e2f0bdf3ae7fbd62e917 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 9 Jan 2025 12:10:28 +1300 Subject: [PATCH] API Stop supporting getCMSValidator --- src/ORM/DataObject.php | 14 -------------- .../GridField/GridFieldDetailFormTest/Person.php | 9 ++++++--- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 28da655b35b..2f0903d4c9b 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2682,21 +2682,7 @@ public function getCMSActions() public function getCMSCompositeValidator(): CompositeValidator { $compositeValidator = CompositeValidator::create(); - - // Support for the old method during the deprecation period - if ($this->hasMethod('getCMSValidator')) { - Deprecation::notice( - '5.4.0', - 'The getCMSValidator() method is deprecated and won\'t be supported in a future major release.' - . ' Override getCMSCompositeValidator() instead.', - Deprecation::SCOPE_GLOBAL - ); - $compositeValidator->addValidator($this->getCMSValidator()); - } - - // Extend validator - forward support, will be supported beyond 5.0.0 $this->invokeWithExtensions('updateCMSCompositeValidator', $compositeValidator); - return $compositeValidator; } diff --git a/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php b/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php index ce97268c0e6..2717fed2019 100644 --- a/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php +++ b/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php @@ -5,6 +5,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; +use SilverStripe\Forms\Validation\CompositeValidator; use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObjectSchema; @@ -65,14 +66,16 @@ public function getCMSFields() return $fields; } - public function getCMSValidator() + public function getCMSCompositeValidator(): CompositeValidator { - return new RequiredFieldsValidator( + $validator = parent::getCMSCompositeValidator(); + $validator->addValidator(new RequiredFieldsValidator( [ 'FirstName', 'Surname' ] - ); + )); + return $validator; } public function getCMSEditLink(): ?string