Auto-populating time portion of a datetime field from a form

I see that if I use the date_select helper in my view, then in the
generated page, my selects are named obj[datetime_field(1i)] (and 2i and
3i for the other parts). These auto-populate the date portion of my
datetime_field.

I have another datetime field that I’m presenting the time from and I
would like to use a similar scheme to autopopulate it. Currently, I’ve
used the :prefix option to select_hour/minute/second to get the
parameter name set correctly, but I end up with a hash with keys ‘hour’,
‘minute’ and ‘second’. I can definitely handle this, but was wondering,
can I just use 4i, 5i, 6i to index into the time portions of a datetime
field?

Thanks,
Wes

Wes G. wrote:

I see that if I use the date_select helper in my view, then in the
generated page, my selects are named obj[datetime_field(1i)] (and 2i and
3i for the other parts). These auto-populate the date portion of my
datetime_field.

I have another datetime field that I’m presenting the time from and I
would like to use a similar scheme to autopopulate it. Currently, I’ve
used the :prefix option to select_hour/minute/second to get the
parameter name set correctly, but I end up with a hash with keys ‘hour’,
‘minute’ and ‘second’. I can definitely handle this, but was wondering,
can I just use 4i, 5i, 6i to index into the time portions of a datetime
field?

Thanks,
Wes

Here’s what I ended up with after reading through the source of
date_helper.rb:

<%= select_hour(@current_job.StartTime, :hour_format => “12”, :prefix =>
‘current_job[StartTime(4i)]’, :discard_type => true) %>:

<%= select_minute(@current_job.StartTime, :prefix =>
‘current_job[StartTime(5i)]’, :discard_type => true) %>:

<%= select_second(@current_job.StartTime, :prefix =>
‘current_job[StartTime(6i)]’, :discard_type => true) %>

Seems to be posting correctly - now some other problem is occurring.

Clear as mud :).

WG