-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Attach the xhr violation error to the form field #7948
Attach the xhr violation error to the form field #7948
Conversation
Can you provide a screenshot of what you get ? |
Guys please merge PR and add a tag |
I'd like the review of @jordisala1991 first |
const field = $(form).find(`[name='${violation.propertyPath}']`); | ||
if (field.length) { | ||
field.closest('.form-group').addClass('has-error xhr-violation-error'); | ||
field.parent().append(`<div class="help-block sonata-ba-field-error-messages xhr-violation-error-block"> |
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.
This won't work if one field triggers 2 validation errors. IMO this code should be written in plain JS, and you can use some (or all) the logic written here: https://github.com/sonata-project/SonataPageBundle/blob/4.x/assets/js/composer.js#L255-L300
It should be quite similar.
Hi @jordisala1991, |
@jordisala1991 please check the pr |
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.
IMO it looks good now, but we also need to move symfony/serializer from require-dev to require. It is a hard dependency
Thank you @ggabrovski |
Attach the xhr violation error to the form field
In relation to @dmitryuk fix for #7945 #7946 it will be nice for the user to see the violation error message attached to the field. I suggest to add small logic to display this information on the right place.
Changelog