patrick99e99
2010-Jan-14 06:59 UTC
how can I add another model to ActionView::Base.field_error_proc ?
Hi,
If I have a form that has attributes for two different models-- if I
do .valid? checks on both instances of the model in the create action
of the controller, then I effectively generate error messages for both
models, and I can see them both by doing
errors_for :model1_instance, :model2_instance.
However, if I style my field_error_proc differently by doing something
like:
ActionView::Base.field_error_proc = Proc.new do |html_tag,
instance_tag|
css_class = /^<label/.match(html_tag) ? ''error_label'' :
''error_field''
"<span
class=''#{css_class}''>#{html_tag}</span>"
end
Then only the fields from the model1_instance (the instance that the
form was dedicated to) have this span class added to them.
My question is, how can I tell ActionView::Base to add model2_instance
to it''s field_error_proc ?
Thank you.
-patrick
--
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.