Wes Gamble
2006-Jul-18 15:09 UTC
[Rails] 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 -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Jul-18 15:35 UTC
[Rails] Re: Auto-populating time portion of a datetime field from a
Wes Gamble 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, > WesHere''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 -- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- Overriding date_select in local project to use custom value rather than blank for starting option...
- Understanding date_select naming conventions
- ERb question: Embedding <%= %> in helper method calls
- Routing and Parameters
- object_transactions plugin w/2.x disables AR session store