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.
9 lines
289 B
Ruby
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
|