Provide possibility of meaningful error messages when using UserForms

This commit is contained in:
tazzydemon 2015-12-07 14:45:07 +13:00 committed by Julian Warren
parent 947d0f09e0
commit 558193c2bb

View File

@ -114,7 +114,14 @@ if (class_exists('EditableFormField')) {
{
$formField = $this->getFormField();
if (!$formField->validate($form->getValidator())) {
$form->addErrorMessage($this->Name, $this->getErrorMessage()->HTML(), 'error', false);
$errorArray = $form->getValidator()->getErrors();
$map = array_map(function ($element) {
return $element['fieldName'];
}, $errorArray);
$errorText = $errorArray[array_search($this->Name, $map)]['message'];
$form->addErrorMessage($this->Name, $errorText, 'error', false);
}
}