Skip to content

Commit

Permalink
API Stop supporting getCMSValidator (#11538)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 9, 2025
1 parent 2f186e7 commit 6752490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/ORM/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 6 additions & 3 deletions tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6752490

Please sign in to comment.