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

Admin: highlight fields with errors #188

Closed
monfresh opened this issue Jul 17, 2014 · 3 comments · Fixed by #222
Closed

Admin: highlight fields with errors #188

monfresh opened this issue Jul 17, 2014 · 3 comments · Fixed by #222

Comments

@monfresh
Copy link
Member

Currently, if a validation error occurs, the error messages are displayed in a red box at the top of the page, but the affected fields themselves are not easy to spot. It would be nice to add a thick red (or other) border around the field with errors. Rails automatically adds a div around the affected fields with a class called "field_with_errors", so it should just be a matter of adding styles for that class.

@alexi215
Copy link

alexi215 commented Aug 1, 2014

Has this been closed out? The admin forms appear to have red highlighting when ever I type in bogus entries on local host (8080).
Sign In
New Locations

@monfresh
Copy link
Member Author

monfresh commented Aug 1, 2014

I don't think this has been fixed yet. I think what you're seeing is the browser's validation. For example, by identifying email fields as type="email", most modern browsers will perform their own validation. This issue is to highlight fields with errors after they have been submitted. One way to try it out is to add a new Contact, then only fill in the email for example, but not the name. The name field should be higlighted after the form is submitted.

@alexi215
Copy link

alexi215 commented Aug 1, 2014

@monfresh you are correct - I'll keep plugging away. Thanks!

monfresh pushed a commit that referenced this issue Sep 4, 2014
Closes #188.

Rails automatically surrounds a field that failed to pass validations
with a div that has a class called `field_with_errors`. For some
reason, this doesn’t get added to serialized fields, so I had to write
custom methods in `form_helper.rb`.

I also updated the HTML for some of the fields so that the highlighted
field would retain the same appearance as the regular field.

While working on this, I realized some of the model validations could
be refactored and simplified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants