Halaman

Rabu, 22 Desember 2010

[shared] change rails form error field wrapper

by default rails wrap all fields that contain error data using div with "fieldWithErrors" class

but sometimes we want to change that wrapper for example to use span instead of div.
that can easily be done by overriding field_error_proc class attribute in ActionView::Base

in environment.rb
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}".html_safe }

file position (for rails 2.3.10):
[ruby_dir]\lib\ruby\gems\1.8\gems\actionpack-2.3.10\lib\action_view\helpers\active_record_helper.rb

Tidak ada komentar:

Posting Komentar