This may be as much a pure HTML question as a Rails question, but I''m just feeling my way through ActionView and need all the help I can get! :) The scenario: A user types a street address into a form and hits return. My app uses Google geocoding services (sweet) to resolve the user input into a full street address. It may resolve into zero addresses (no match), one address (exact match), or multiple addresses (partial match). From this, I want to render a form that lets the user verify his or her street address. In the zero match case, I can flash an error message saying there were no matches and re-render the original form. With one or more matches, I want a "this is my address" button next to each resolved address to let the user verify his or her address: <label>type your address: <text field>15 wayland street <button>[this is my address] <label>15 wayland st, atlanta, ny 14808 <button>[this is my address] <label>15 wayland st, boston, ma 02125 <button>[this is my address] <label>15 wayland st, sherrill, ny 13461 What I''m not at all sure about is the parameters to add to each submit button. I want the button label to say "this is my address", but pass a fully resolved address to the server depending on which button is pushed. I tried :name => candidate.full_address, :value => "this is my address" -- I could make that work, but the parameters passed to my server are ''backwards'' (key = full_address, value = "this is my address"). So my question is: how would you structure a Rails form to do this? Assume @premise is the controller, and that @candidates is a list of candidate addresses. TIA. -- 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.
Philip Hallstrom
2010-Nov-04 00:32 UTC
Re: choose one of N: single form or multiple forms?
> This may be as much a pure HTML question as a Rails question, but I''m > just feeling my way through ActionView and need all the help I can get! > :) > > The scenario: A user types a street address into a form and hits return. > My app uses Google geocoding services (sweet) to resolve the user input > into a full street address. It may resolve into zero addresses (no > match), one address (exact match), or multiple addresses (partial > match). > > From this, I want to render a form that lets the user verify his or her > street address. In the zero match case, I can flash an error message > saying there were no matches and re-render the original form. With one > or more matches, I want a "this is my address" button next to each > resolved address to let the user verify his or her address: > > <label>type your address: <text field>15 wayland street > <button>[this is my address] <label>15 wayland st, atlanta, ny 14808 > <button>[this is my address] <label>15 wayland st, boston, ma 02125 > <button>[this is my address] <label>15 wayland st, sherrill, ny 13461 > > What I''m not at all sure about is the parameters to add to each submit > button. I want the button label to say "this is my address", but pass a > fully resolved address to the server depending on which button is > pushed. I tried :name => candidate.full_address, :value => "this is my > address" -- I could make that work, but the parameters passed to my > server are ''backwards'' (key = full_address, value = "this is my > address"). > > So my question is: how would you structure a Rails form to do this? > Assume @premise is the controller, and that @candidates is a list of > candidate addresses.You could use button_to unless you''re already inside a form. Or use link_to and pass all the params, styling the link to look like a button. Or use javascript to populate the form with the details when they click the button. -philip -- 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.
@phillip: thanks for the suggestions. Upon reflection, since the Google geocoder is already set up for client-side javascript queries, that''s probably the best way to go. - ff -- 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.