Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails form errors - validation

I'd like to be able to highlight fields that don't pass validation. I'm using simple_form, and the error messages it displays just don't look good to me. I'm listing the errors above the form & I'd like to highlight (change the color of) the fields that contain invalid values. Is there an easy way of doing this?

like image 884
Chip Avatar asked Feb 24 '23 20:02

Chip


1 Answers

yes it's very easy, you will likely find that the field with errors will have a class of ".field_with_errors" or something similar applied to it

just style all inputs that fall within that class to have 2px solid red border

i.e.

// style.sass
.field_with_errors
  input
    border: 2px solid red
like image 84
stephenmurdoch Avatar answered Feb 26 '23 21:02

stephenmurdoch