diff --git a/code/Model/EditableFormField.php b/code/Model/EditableFormField.php index 986787e6..46aee2c7 100755 --- a/code/Model/EditableFormField.php +++ b/code/Model/EditableFormField.php @@ -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; @@ -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; } /** diff --git a/code/UserForm.php b/code/UserForm.php index e7eb1686..e4370859 100644 --- a/code/UserForm.php +++ b/code/UserForm.php @@ -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; @@ -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; } }