openstreetmap-website/config/initializers/field_error.rb
Tom Hughes 933b091330 Highlight erroneous fields by adding a class to them
The default rails scheme for highlighting errors is to wrap the
field in a div, but that changes the structure of the page and can
change the meaning of CSS rules applied to the fields.

As an alternative we now apply a class to the fields, and use that
in the CSS to apply a highlight.
2014-01-15 21:41:16 +00:00

9 lines
289 B
Ruby

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
class_attr_index = html_tag.index 'class="'
if class_attr_index
html_tag.insert class_attr_index+7, 'field_with_errors '
else
html_tag.insert html_tag.index(/\/?>/), ' class="field_with_errors"'
end
end