Hello, I''ve been reading that Rails 3 offers a bunch of new validation features. Is there a way to customize the validation error formatting? For example, I prefer to style the elements surrounding a form input containing an error, not just the input itself. Also, I might like to define my own class names for styling these elements, for example if they don''t conform to my naming standards. Is this easier in Rails 3 than in 2? I found a few articles about new validation functionality, but they seem to be formatting the old way. Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Since I have no experience Rails 2, I can''t compare the two. However, it''s pretty easy with Rails 3. You can override the default behavior like so: ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| *** YOUR CODE HERE *** end The README that comes with the ActionPack gem has a more verbose explanation about this. (I just wish there was a way to tell it to add some kind of styling if a field validated properly!) On May 11, 6:08 pm, Mike <djan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, I''ve been reading that Rails 3 offers a bunch of new validation > features. > > Is there a way to customize the validation error formatting? For > example, I prefer to style the elements surrounding a form input > containing an error, not just the input itself. > > Also, I might like to define my own class names for styling these > elements, for example if they don''t conform to my naming standards. > > Is this easier in Rails 3 than in 2? > > I found a few articles about new validation functionality, but they > seem to be formatting the old way. > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello, thanks for your response. I''m looking at actionpack-3.0.0.beta3/README and can''t find any mention of this. Using the example below, is there a way to style the elements surrounding the invalid input (and not just the input itself)? I''d like to change the CSS class name, too. Basically I''d like to customize validation without adding a ton of overhead to the framework''s existing procedures. On May 13, 11:20 pm, cult hero <binarypala...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Since I have no experience Rails 2, I can''t compare the two. However, > it''s pretty easy with Rails 3. You can override the default behavior > like so: > > ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| > *** YOUR CODE HERE *** > end-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.