Guest User

Untitled

a guest
Jan 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #Overrides the default way how rails marks form fields with errors.
  2. #In this version, it only adds the class 'error' to label and element
  3.  
  4. ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
  5. if html_tag =~ /<(input|label|textarea|select)/
  6. html_field = Nokogiri::HTML::DocumentFragment.parse(html_tag)
  7. html_field.children.add_class 'error'
  8. html_field.to_s
  9. else
  10. html_tag
  11. end
  12. end
Add Comment
Please, Sign In to add comment