I'm working a project that has recurring, weekly events. Thus, I use several DateTime fields in a nontraditional way. What I'm working on is a FormBuilder that creates a field that outputs a select for a weekday, and a select for time. I'm using a twelve-hour plugin I found online, so that works:
class ActionView::Helpers::FormBuilder
def dow_time(dow,time,options={})
rval = select(dow, DateTime::DAYNAMES)
rval += time_select(time, {:minute_step => 15, :ignore_date => false, :twelve_hour => true})
end
end
The problem I'm having is that the weekday select doesn't actually have a default selected value. This works fine on my create pages, but not on the edit pages. dow is a symbol that references the field in the calling model where the day of the week string is "Monday", "Tuesday", etc. How can I pull that value out of the calling model using dow.
self[dow]
Doesn't work since this is in a different class.
Any ideas? Something different?