Skip to content

Commit

Permalink
API Replace getCMSValidator with getCMSCompositeValidator (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 9, 2025
1 parent 394d32a commit b314413
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions code/Model/EditableFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\HasManyList;
use SilverStripe\Core\Validation\ValidationException;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension;
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroupEnd;
Expand Down Expand Up @@ -924,13 +925,11 @@ public function getEditableFieldClasses($includeLiterals = true)
return $editableFieldClasses;
}

/**
* @return EditableFormField\Validator
*/
public function getCMSValidator()
public function getCMSCompositeValidator(): CompositeValidator
{
return EditableFormField\Validator::create()
->setRecord($this);
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(EditableFormField\Validator::create()->setRecord($this));
return $validator;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions code/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use SilverStripe\Forms\LabelField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DB;
use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension;
Expand Down Expand Up @@ -374,11 +375,10 @@ public function getErrorContainerID()
return $this->config()->get('error_container_id');
}

/**
* Validate formfields
*/
public function getCMSValidator()
public function getCMSCompositeValidator(): CompositeValidator
{
return UserFormValidator::create();
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(UserFormValidator::create());
return $validator;
}
}

0 comments on commit b314413

Please sign in to comment.