Skip to content
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

setError doesn't work as expected, returns key instead of the key provided #96

Closed
erip2 opened this issue Sep 9, 2024 · 2 comments · Fixed by #97
Closed

setError doesn't work as expected, returns key instead of the key provided #96

erip2 opened this issue Sep 9, 2024 · 2 comments · Fixed by #97
Assignees
Labels

Comments

@erip2
Copy link

erip2 commented Sep 9, 2024

Laravel Precognition Plugin Version

0.5.8

Laravel Version

11.0

Plugin

Vue w/ Inertia

Description

The form.setError doesn't work as it does with the Inertia useForm helper.

I want to do a quick front-end validation before I send the data on the server, in cases where the user can't add some data if some other data is empty.

I noticed that when using the laravel-precognition-vue-inertia' the errors aren't shown, and that's because the form errors object is like this:

errors:
  key: "Shipping Cost is required."

from the Vue Developer tools. Normally should be { 'shipping_cost': "Shipping Cost is required" } as the function is called like this: form.setError('shipping_cost', 'Shipping Cost is required').

I debugged it and noticed that for some reason, the object is returned with key instead of the input name:

Screenshot 2024-09-09 at 15 23 56

Steps To Reproduce

  • Create an Inertia/Laravel project
  • Use the laravel-precognition-vue-inertia useForm
  • Try to set an error manually with setError function
@timacdonald
Copy link
Member

PR up to fix this one. Will close this and we can follow along in that PR: #97

@timacdonald
Copy link
Member

Thanks for reporting this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants