Skip to content
xrorox edited this page Oct 19, 2011 · 6 revisions

You can custom the html output this way on client_side_validations 3.1.0 :

in config/initializes/client_side_validations.rb

require 'client_side_validations/simple_form' if defined?(::SimpleForm) require 'client_side_validations/formtastic' if defined?(::Formtastic)

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| unless html_tag =~ /^<label/ %{

#{html_tag}
#{instance.error_message.first}
}.html_safe else %{
#{html_tag}
}.html_safe end end

You have to keep

and you must keep the same class for the label and the non-label output. You can change the name of this css class, but both should match as shown here.

example : this works :

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| unless html_tag =~ /^<label/ %{

#{html_tag}
#{instance.error_message.first}
}.html_safe else %{
#{html_tag}
}.html_safe end end

This won't :

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| unless html_tag =~ /^<label/ %{

#{html_tag}
#{instance.error_message.first}
}.html_safe else %{
#{html_tag}
}.html_safe end end
Clone this wiki locally