tadman, could you expand on the line "You can build off this functionality by naming your fields the same way."
My model has when:datetime for storing the user-entered date and time that an event should be scheduled for. I'm using a jQuery plugin that puts up a nice calendar for the year/month/day portion of the datetime.
So my trouble is in getting the hour and minute from time_select. The hour&minute gets passed back as when(5i) and doesn't get encoded into the year/month properly. By looking at the SQL Insert statement that got executed, I can see what gets encoded into when, but the hour the user chose has become the year and the month and day are 1 and 1.
My guess is that if I understood your comment I would need to supply (somehow) when(1i), when(2i) and when(3i) to the year/month/day jQuery selector, and when(4i), when(5i) to the time_select.
But all variations I've tried to do that have failed when the form layout tries to load.
Here's the view code:
<%= f.label "What date is the event?" %>
<%= f.text_field :when %>
<%= f.label "What time should recording begin?" %>
<%= time_select :request, :when, { :default => Time.now.change(:hour => 21), :simple_time_select => true, :minute_interval => 20, :time_separator => "" } %>
Here's the generated html:
<label for="request_What date is the event">What date is the event?</label>
<input id="request_when" name="request[when]" size="30" type="text" />
<label for="request_What time should recording begin">What time should recording begin?</label>
<select id="request_when_5i" name="request[when(5i)]">
< A Day Goes By With More Learning and Gnashing of Teeth >
I added three lines to my create action in my controller to rebuild the "when" attribute for my model, merging together the Y/M/D info with the HH:MM info --
foo = @request.when.to_datetime
bar = params[:request]["when(5i)"]
@request.when = Time.parse("#{foo.month}/#{foo.day}/#{foo.year} #{bar}")
Which was followed by the normal "if @request.save......."
This application is still a Rails 2.3.5 application