add support for DateTime objects

This commit is contained in:
John Bintz 2013-01-17 15:10:29 -05:00
parent eb7fdc6e10
commit 8cb6e437a0
1 changed files with 9 additions and 0 deletions

View File

@ -24,6 +24,15 @@ class SeparateDateAndTimePickerInput < Formtastic::Inputs::DatetimePickerInput
value_parts.last value_parts.last
end end
def value
return options[:input_html][:value] if options[:input_html] && options[:input_html].key?(:value)
val = object.send(method)
return val.strftime('%Y-%m-%d %H:%M') if val.kind_of?(DateTime)
super
end
def value_parts def value_parts
@value_parts ||= (value || '').split(' ') @value_parts ||= (value || '').split(' ')
end end