-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Exposed :key (in addition to :message) #30
Conversation
I have a use case where I could do with :key exposed. If I echo out my errors, on some occasions I output the errors in a single block then treat them using JS (usually moving them to an element on the page by the ID stored in a data attribute). If I want to print <li data-key=":key">:message</li>, I cannot currently access the :key part (where :key is the ID of the associated field). Being able to do this (as adjusted) allows a user to identify exactly what field an individual message was associated with e.g. when using ->all(), and is a simple exposure of data already held.
Please take into account Laravel's coding standards:
|
Updates following comments by franzliedke
@franzliedke I think corrected it as I understand from what you've said. Apologies for the basic error, still getting to grips with keeping my work super neat! |
Are you able to provide a couple of tests for this? I think this is pretty sweet :) |
+1 to @bencorlett it would be nice to have some tests. Let's try and keep the code coverage for L4 as high as possible shall we chaps? |
Done. I added tests. |
I have found use case where I could do with the key of the error array exposed (proposing :key).
If I echo out my errors, on some occasions I output the errors in a single block then treat them using JS (usually moving them to an element on the page by the ID stored in a data attribute).
If I want to print
Being able to do this (as adjusted) allows a user to identify exactly what field an individual message was associated with e.g. when using ->all(), and is a simple exposure of data already held in the object.
Example:
Format: