some AR and processor updates

This commit is contained in:
John Bintz 2012-12-12 13:15:18 -05:00
parent 59e8bd2eb3
commit 3223b019eb
2 changed files with 11 additions and 5 deletions

View File

@ -2,10 +2,8 @@ require 'formtastic-separate_html5_date_and_time/processor'
module ActiveRecord
module ProcessSeparateDateAndTimePickerInputs
def assign_multiparameter_attributes(attrs)
Formtastic::SeparateDateAndTimePickerInput::Processor.process(attrs).each do |attribute, value|
public_send("#{attribute}=", value)
end
def assign_attributes(attrs = nil, *args)
super Formtastic::SeparateDateAndTimePickerInput::Processor.process(attrs), *args
end
def update_attributes(attrs = nil)
@ -13,3 +11,4 @@ module ActiveRecord
end
end
end

View File

@ -15,7 +15,13 @@ module Formtastic
end
datetime_attrs.each do |attr, values|
attrs[attr] = values["#{attr}(date)"] + ' ' + values["#{attr}(time)"]
if !values["#{attr}(date)"].blank?
value = (values["#{attr}(date)"] + ' ' + values["#{attr}(time)"]).strip
if !value.blank?
attrs[attr.to_sym] = value
end
end
attrs.delete("#{attr}(date)")
attrs.delete("#{attr}(time)")
@ -27,3 +33,4 @@ module Formtastic
end
end
end