adnan khan
2011-Apr-27 09:34 UTC
Rails doesn''t populate dynamic generated fields on error on posting
In our raols application we have a page where upon submit we save data in db. On this page, we have some fields which are dynamically generated and I see that in case of a validation error when page reloads it doesn''t populate these fields with the values present upon posting. In controller we have the following method defined for populating it: def build_my_registration_type_memberships @memberships [] ListCache.my_registration_types.each do | my_registration_type| @memberships << MyRegistrationTypeMembership.find_or_initialize_by_my_id_and_my_registration_type_id( @my.id, my_registration_type.id ) end end In above method when my registration is opened in edit/view mode, it shows the values using this @membership method. But on posting in case of error it doesn''t reload this with correct information. So my question is how could I repopulate @membership in case of an error on posting? Thanks for help. -- 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.
Robert Walker
2011-Apr-30 04:01 UTC
Re: Rails doesn''t populate dynamic generated fields on error on posting
adnan khan wrote in post #995336:> In our raols application we have a page where upon submit we save data > in db. On this page, we have some fields which are dynamically > generated and I see that in case of a validation error when page > reloads it doesn''t populate these fields with the values present upon > posting.What do you mean by your fields being dynamically generated? It''s the normal case for all the fields, along with the form itself, to be dynamically generated in Rails applications. That''s what form helper methods do. Do you mean you''re adding them with JavaScript? If that''s the case then JavaScript would be needed to manage their contents as well. -- Posted via http://www.ruby-forum.com/. -- 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.