[Rails] Overriding

Marcel Molina Jr.
Sat, 25 Mar 2006 02:28:08 -0000

On Sat, Mar 25, 2006 at 01:22:05PM +1100, Dan Harper
wrote:
> Does anyone know how to override the <div
class="fieldWithErrors">
> behaviour when a form field is incorrect?

This is what ActionView does:

module ActionView
  class Base
    @@field_error_proc = Proc.new{ |html_tag, instance| "<div
class=\"fieldWithErrors\">#{html_tag} " }
    cattr_accessor :field_error_proc
  end
end

You can set your own Proc. For example, in your config/environment.rb:

ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|  %(<span
class="field-with-errors">#{html_tag})}

marcel
--
Marcel Molina Jr. <marcel@vernix.org>