10 lines
309 B
Ruby
10 lines
309 B
Ruby
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
|
if html_tag.match('class')
|
|
html_tag.gsub(/class="(.*?)"/, 'class="\1 field_with_errors"').html_safe
|
|
else
|
|
parts = html_tag.split('>', 2)
|
|
parts[0] += ' class="field_with_errors">'
|
|
(parts[0] + parts[1]).html_safe
|
|
end
|
|
end
|