Skip to content

Instantly share code, notes, and snippets.

@webchi
Created March 19, 2012 00:56
Show Gist options
  • Save webchi/2088226 to your computer and use it in GitHub Desktop.
Save webchi/2088226 to your computer and use it in GitHub Desktop.
Custom form error messages for rails and yaml.de css framework
# This this replacemnt for default rails field_with_errors for using http://www.yaml.de/docs/index.html#yaml-forms
# Add this to ./config/environment.rb file
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<label/
%|<div class="ym-error"><p class="ym-message">#{[instance.error_message].join(', ')}</p>#{html_tag}</div>|.html_safe
else
%|<div class="ym-error">#{html_tag}</div>|.html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment