From d1a62712357c8d329f5aad1f24d8ca59c548b065 Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Mon, 5 Oct 2015 16:28:38 +1300 Subject: [PATCH] Fix error message to return the proper error with validate --- code/EditableSpamProtectionField.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/EditableSpamProtectionField.php b/code/EditableSpamProtectionField.php index 965e01b..c5088c4 100644 --- a/code/EditableSpamProtectionField.php +++ b/code/EditableSpamProtectionField.php @@ -106,8 +106,12 @@ if(class_exists('EditableFormField')) { public function validateField($data, $form) { $formField = $this->getFormField(); - if (!$formField->validate($form->getValidator())) { - $form->addErrorMessage($this->Name, $this->getErrorMessage()->HTML(), 'error', false); + $validator = $form->getValidator(); + if (!$formField->validate($validator)) { + foreach($validator->getErrors() as $error) { + $this->owner->CustomErrorMessage = $error['message']; + $form->addErrorMessage($this->Name, $this->getErrorMessage()->HTML(), 'error', false); + } } }