[PATCH conductor] BZ798550 fixed field_with_errors is by default generated by rails as a div, wchich breaks the layout because its put inside <p>. This patch forces rails to generate field_with_errors as span element.

Tomáš Hrčka thrcka at redhat.com
Thu Mar 15 09:09:34 UTC 2012


On 03/14/2012 02:55 PM, jtomasek at redhat.com wrote:
> From: Jiri Tomasek<jtomasek at redhat.com>
>
> http://www.rabbitcreative.com/2010/09/20/rails-3-still-fucking-up-field_with_errors/
> ---
>   src/app/views/catalogs/_form.html.haml |    4 ++--
>   src/config/application.rb              |    7 +++++++
>   2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/app/views/catalogs/_form.html.haml b/src/app/views/catalogs/_form.html.haml
> index eb88f48..12d3bba 100644
> --- a/src/app/views/catalogs/_form.html.haml
> +++ b/src/app/views/catalogs/_form.html.haml
> @@ -1,10 +1,10 @@
>   - if @catalog.errors.any?
>     = render 'layouts/error_messages', :object =>  @catalog
>   %fieldset
> -  %p
> +  %p.clearfix
>       = form.label :name
>       = form.text_field :name, :class =>  'em long'
> -  %p
> +  %p.clearfix
>       = form.label :pool_id
>       = form.select(:pool_id, @pools.collect{|p| [p.name, p.id]}, :prompt =>   t("catalogs.form.select_pool"))
>
> diff --git a/src/config/application.rb b/src/config/application.rb
> index 9c0949f..d1c2a7b 100644
> --- a/src/config/application.rb
> +++ b/src/config/application.rb
> @@ -97,6 +97,13 @@ module Conductor
>       # Configure sensitive parameters which will be filtered from the log file.
>       config.filter_parameters += [:password, :password_confirmation]
>
> +    #field_with_errors should be span instead of div
> +    #http://www.rabbitcreative.com/2010/09/20/rails-3-still-fucking-up-field_with_errors/
> +    ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
> +      include ActionView::Helpers::RawOutputHelper
> +      raw %(<span class="field_with_errors">#{html_tag}</span>)
> +    end
> +
>       config.after_initialize do
>         Haml::Template.options[:format] = :html5
>       end
ACK.



More information about the aeolus-devel mailing list