-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: form-level error reporting #1
Conversation
One question I have tho, this was a feature I implemented out of the specs, but not sure how useful it is, as you're using it do you think it is a useful feature? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this feature was to set a global error message by the form name or another if specified, meaning it should by default be the name of the form, just was not meant to set the name of the field as the error but the global error itself.
Something like if you have a global error in laravel, you can just pass the name of the form field in the errors field and it would display there.
node.setErrors(hasGlobalError ? formErrorMessage : [], errors)
should be this.
I never use form-level errors, but I can see how someone might want to show one. When using Form Requests with Laravel, you usually attach errors only to the fields though. |
Not sure I'm following. My understanding was that by setting For example, say you have a login form, and submitting the form with invalid credentials would return the following error bag: {
"email": "Invalid credentials"
} You would set |
That was not the reason but it could be too, but I would say for this its better to use other ways directly into the FormKit. The thing I meant is is there an error like "The user was not created, call your IT". It is a global error. {
userForm: 'The user was not created, call your IT',
}
<FormKit type="form" name="userForm">
</FormKit> |
I believe this should do it. |
This looks good I will work on it to publish a new version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thanks ! |
This will be fixed after publishing |
Hey @fenilli, not meaning to press, but are you planning to release 0.1.6 soon-ish? No biggie if you don't have time, I can definitely fork in the meantime. |
@justin-schroeder did you publish to npm? |
This PR fixes an issue where form-level errors were set to the node's name when
formLevelErrorName
was left unspecified.Specifying
formLevelErrorName
will now correctly render a form-level error if an error with the key specified byformLevelErrorName
exists in the response payload. Also, leavingformLevelErrorName
unspecified will ensure no form-level errors are displayed.FYI @fenilli