mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
Provide possibility of meaningful error messages when using UserForms
This commit is contained in:
parent
947d0f09e0
commit
558193c2bb
@ -114,7 +114,14 @@ if (class_exists('EditableFormField')) {
|
|||||||
{
|
{
|
||||||
$formField = $this->getFormField();
|
$formField = $this->getFormField();
|
||||||
if (!$formField->validate($form->getValidator())) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user