A free open source IT asset/license management system
Show better validation messages on custom field validation errors
snipe07e59ad36205
diff --git a/app/Livewire/CustomFieldEditor.php b/app/Livewire/CustomFieldEditor.phpindex d9ffd275dc..a50d0859a9 100644--- a/app/Livewire/CustomFieldEditor.php+++ b/app/Livewire/CustomFieldEditor.php@@ -368,6 +368,23 @@ class CustomFieldEditor extends Componentreturn;}+ // ValidatingTrait::save() returns false on validation failure+ // without throwing, stashing the actual messages on+ // $field->getErrors(). Surface those directly against their+ // attributes so the admin sees "The name has already been+ // taken" (or whatever) instead of a generic "please try+ // again" with no additional context.+ $errors = $field->getErrors();+ if ($errors->isNotEmpty()) {+ foreach ($errors->messages() as $attribute => $messages) {+ foreach ($messages as $message) {+ $this->addError($attribute, $message);+ }+ }++ return;+ }+$this->addError('name',$this->isEdit