Hi, a brief description of my situation: I have 2 models, Item and SellerContactInfo. They have to be filled with data from the user, which is done in a 2-step web form. I''m thinking heavily about the optimal way to do this: A) Create 2 actions inside the same controller, use the session to store the Item object and persist both objects to the db after the 2nd form has been completed, or B) Create both forms on one HTML page, switch between them by showing/hiding DIVs. Problem in this case: if the user fills out the 2nd form and then validation fails for the 1st form, he/she will be thrown back at the first form which reduces usability in my opinion. Anyone have a usable idea of how to optimally solve this situation? thx, Robert -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
C) Create one action. Use request.post? To see if they''re just arriving or have posted the form. Then use another if statement based on the submit button''s value to see which form part has been submitted. If it''s the first part, you can do your validation, store information in the session and display the second part of the form. If the second form has been submitted, you can do that validation and store your data. Would that work? Jason Robert Spielmann wrote:> Hi, > > a brief description of my situation: I have 2 models, Item and > SellerContactInfo. They have to be filled with data from the user, which > is done in a 2-step web form. I''m thinking heavily about the optimal way > to do this: > > A) Create 2 actions inside the same controller, use the session to store > the Item object and persist both objects to the db after the 2nd form > has been completed, > > or > > B) Create both forms on one HTML page, switch between them by > showing/hiding DIVs. Problem in this case: if the user fills out the 2nd > form and then validation fails for the 1st form, he/she will be thrown > back at the first form which reduces usability in my opinion. > > Anyone have a usable idea of how to optimally solve this situation? > > thx, > Robert > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 28 September 2006 17:31, Robert Spielmann wrote:> a brief description of my situation: I have 2 models, Item and > SellerContactInfo. They have to be filled with data from the user, which > is done in a 2-step web form. I''m thinking heavily about the optimal way > to do this: > > A) Create 2 actions inside the same controller, use the session to store > the Item object and persist both objects to the db after the 2nd form > has been completed, > > or > > B) Create both forms on one HTML page, switch between them by > showing/hiding DIVs. Problem in this case: if the user fills out the 2nd > form and then validation fails for the 1st form, he/she will be thrown > back at the first form which reduces usability in my opinion.I wouldn''t go with showing/hiding DIVs.. It''s too problematic for me. You can just make 3 actions (2 actions - for two forms and one to store data in DB and redirect), submit first form to second action, and second form - to third. When validation of first form in second action fails, just display first template (the same with second form). All submitted data could be stored in hidden fields so you don''t need to mess up with sessions. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''ll try, thanks for sharing the idea :) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---