Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Stop supporting getCMSValidator #11538

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading