From 8cb6e437a0216a4feaf8f610f0e0112b3ede3d61 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 17 Jan 2013 15:10:29 -0500 Subject: [PATCH] add support for DateTime objects --- .../formtastic.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/formtastic-separate_html5_date_and_time/formtastic.rb b/lib/formtastic-separate_html5_date_and_time/formtastic.rb index 8c6ed09..720e6ce 100644 --- a/lib/formtastic-separate_html5_date_and_time/formtastic.rb +++ b/lib/formtastic-separate_html5_date_and_time/formtastic.rb @@ -24,6 +24,15 @@ class SeparateDateAndTimePickerInput < Formtastic::Inputs::DatetimePickerInput value_parts.last 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 @value_parts ||= (value || '').split(' ') end