Sickness and insomnia strike and so I’m sat up getting my pet-project up on Edge Rails and trying to get a mixed form working. Unfortunately, it’s something I’m not getting too far with.
Here’s the scenario, I have a form that contains areas for visitors to enter two addresses, billing and delivery. Within these forms I want to be able to provide users with the ability to enter their postcode and have their address automagically filled via. a webservice.
However, these addresses are merely objects that compose part of an outer object—`Order`. So, an order contains both a `billing_address` and `delivery_address`. The visitor needs to be able to submit the form and have the booking saved.
I have to own up to having been somewhat mollycuddled by ASP.NET’s Postback model, abstracting me from HTTP’s inherent request/response model.
Originally I expected to just be able to have a form within a form. So, along the lines of:
<%= start_form_tag(:action => "save") %> ... <%= form_remote_tag(:update => "results" %> ... <%= end_form_tag %> ... <%= text_field_tag :outer_field1 %> <%= text_field_tag :outer_field2 %> ... <%= submit_tag "Save" %><%= end_form_tag %>
And then I would be able to post the inner form, have it’s results updated and then when I wanted to post the whole form (i.e. the 2 outer fields) I could do and the info would be posted to `save`. Unfortunately, that doesn’t seem to be the behaviour.
So, I’m trying to decide how best to proceed. My first thoughts were to follow ASP.NET’s design and include hidden field/s that would let me be able to determine what action the user had just performed.
Ah well, for the time being I’m open to suggestions, time to try and get some sleep!