Summary
grav-plugin-login emits onFormValidationError with only a generic message for several validation failures (e.g. duplicate email/username), but does not provide per-field messages.
As a result, Form plugin templates cannot attach errors to specific inputs (has-errors, inline field messages), and only top-level alert is shown.
Environment
- PHP 8.2
- Latest plugins:
login, form
Reproduction
- Enable public registration with Login plugin.
- Try to register with an email that already exists.
- Observe error output in form.
Actual behavior
- Only generic form error is shown (top message).
- No field-level error for
email.
- No
has-errors class for the email field in default Form rendering.
Expected behavior
- Validation events should include field-scoped messages, for example:
$this->grav->fireEvent('onFormValidationError', new Event([
'form' => $form,
'message' => $language->translate(['PLUGIN_LOGIN.EMAIL_NOT_AVAILABLE', $email]),
'messages' => [
'email' => [
$language->translate(['PLUGIN_LOGIN.EMAIL_NOT_AVAILABLE', $email])
]
]
]));
So Form plugin can render inline error under the correct input.
Where this happens in login.php
Duplicate username/email during registration (processUserRegistration()):
- username check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L827-L835
- email check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L842-L850
Duplicate username/email during profile update (processUserProfile()):
- username check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L999-L1007
- email check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L1017-L1025
These events currently pass message but not messages.
Related issue / same mechanism
grav-plugin-form issue showing the same pattern (generic message without field mapping):
That issue is in another plugin path (captcha in Form), but mechanism is identical: without messages[field], inline field error rendering does not work.
Summary
grav-plugin-loginemitsonFormValidationErrorwith only a genericmessagefor several validation failures (e.g. duplicate email/username), but does not provide per-fieldmessages.As a result, Form plugin templates cannot attach errors to specific inputs (
has-errors, inline field messages), and only top-level alert is shown.Environment
login,formReproduction
Actual behavior
email.has-errorsclass for theemailfield in default Form rendering.Expected behavior
So Form plugin can render inline error under the correct input.
Where this happens in
login.phpDuplicate username/email during registration (
processUserRegistration()):- username check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L827-L835
- email check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L842-L850
Duplicate username/email during profile update (
processUserProfile()):- username check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L999-L1007
- email check: https://github.com/getgrav/grav-plugin-login/blob/develop/login.php#L1017-L1025
These events currently pass
messagebut notmessages.Related issue / same mechanism
grav-plugin-formissue showing the same pattern (generic message without field mapping):CaptchaManagerdoesn't set per-fieldmessageson failure, breakinghas-errorshighlighting grav-plugin-form#627That issue is in another plugin path (captcha in Form), but mechanism is identical: without
messages[field], inline field error rendering does not work.