If the Model includes a "property :start_date, DateTime"
but in the UI form we separate the date and time portions into two
fields.
(So user can enter "30/11/2009" in one textbox and "11:31" in the
other.)
When the form is submitted we need to validate both UI fields and
merge them into the one field in the model.
To merge the start_time with the start_date I'm using:
def start_time=(time_str);
d = self.start_date
t = DateTime.strptime(time_str, '%H:%M')
return self.start_date = DateTime.civil(d.year, d.month, d.day,
t.hour, t.min)
end
Question is, what's the best way to dm validate the start_time field
before attempting to merge it with the date?
The start_time is not a dm field so that is presumably why I cannot
use:
validates_format :start_time, :with => /^[0-2]?[0-9]:[0-6]
[0-9]$/, :message => "oops "
cheers,
George
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.