Overriding <div class="fieldWithErrors">

View: New views
6 Messages — Rating Filter:   Alert me  

Overriding <div class="fieldWithErrors">

by Dan Harper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Does anyone know how to override the <div class="fieldWithErrors">
behaviour when a form field is incorrect?

Thanks,
Dan

_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails

Re: Overriding <div class="fieldWithErrors">

by Marcel Molina Jr. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Mar 25, 2006 at 01:22:05PM +1100, Dan Harper wrote:
> Does anyone know how to override the <div class="fieldWithErrors">
> behaviour when a form field is incorrect?

This is what ActionView does:

module ActionView
  class Base
    @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>" }
    cattr_accessor :field_error_proc
  end
end

You can set your own Proc. For example, in your config/environment.rb:

ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|  %(<span class="field-with-errors">#{html_tag}</span>)}

marcel
--
Marcel Molina Jr. <marcel@...>
_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails

Re: Overriding <div class="fieldWithErrors">

by Dan Harper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some more information may help.  Having the "div" tags makes my HTML
invalid, so instead a "span" tag would be more appropriate.

Thanks,
Dan


Dan Harper wrote:

> Does anyone know how to override the <div class="fieldWithErrors">
> behaviour when a form field is incorrect?
>
> Thanks,
> Dan
>
> _______________________________________________
> Rails mailing list
> Rails@...
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>

_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails

Re: Overriding <div class="fieldWithErrors">

by Dan Harper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Marcel Molina Jr. wrote:
> You can set your own Proc. For example, in your config/environment.rb:
>
> ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|  %(<span class="field-with-errors">#{html_tag}</span>)}
>  
Cool thanks.  That worked a treat.

Dan

_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails

Re: Overriding <div class="fieldWithErrors">

by Ben Munat :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Let me guess... inside a td, right?

b

Dan Harper wrote:

> Some more information may help.  Having the "div" tags makes my HTML
> invalid, so instead a "span" tag would be more appropriate.
>
> Thanks,
> Dan
>
>
> Dan Harper wrote:
>
>> Does anyone know how to override the <div class="fieldWithErrors">
>> behaviour when a form field is incorrect?
>>
>> Thanks,
>> Dan
>>
>> _______________________________________________
>> Rails mailing list
>> Rails@...
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>>
>>
>
> _______________________________________________
> Rails mailing list
> Rails@...
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails

Re: Overriding <div class="fieldWithErrors">

by Dan Harper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ben Munat wrote:
> Let me guess... inside a td, right?
>
> b

Actually no, it was inside a <p>.  I was using <p> to group form
sections together.

Dan

_______________________________________________
Rails mailing list
Rails@...
http://lists.rubyonrails.org/mailman/listinfo/rails