Rails 3: “field-with-errors” wrapper changes the page appearance. How to avoid this?
Rails 3: “field-with-errors” wrapper changes the page appearance. How to avoid this?
Default ActionView::Base.field_error_proc. Its currently defined within ActionView::Base:
@@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
Using class inside config/application.rb:
config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }
The div element is a block element. Add style CSS file to make it inline element:
.field_with_errors { display: inline; }
Follow this command:
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, 'error ' else html_tag.insert html_tag.index('>'), ' class="error"' end end