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 ActiveRecord
module ProcessSeparateDateAndTimePickerInputs module ProcessSeparateDateAndTimePickerInputs
def assign_multiparameter_attributes(attrs) def assign_attributes(attrs = nil, *args)
Formtastic::SeparateDateAndTimePickerInput::Processor.process(attrs).each do |attribute, value| super Formtastic::SeparateDateAndTimePickerInput::Processor.process(attrs), *args
public_send("#{attribute}=", value)
end
end end
def update_attributes(attrs = nil) def update_attributes(attrs = nil)
@ -13,3 +11,4 @@ module ActiveRecord
end end
end end
end end

View File

@ -15,7 +15,13 @@ module Formtastic
end end
datetime_attrs.each do |attr, values| 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}(date)")
attrs.delete("#{attr}(time)") attrs.delete("#{attr}(time)")
@ -27,3 +33,4 @@ module Formtastic
end end
end end
end end