Sha256: a7eefa479517530c050a774e8cc2daa2879a0793f235563f0d51254dc6797ede
Contents?: true
Size: 1.14 KB
Versions: 8
Compression:
Stored size: 1.14 KB
Contents
module DatePicker module FormHelper def self.field_id(object_name, attribute) object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"") + "_" + attribute.to_s end def self.included(base) ActionView::Helpers::FormBuilder.instance_eval do include FormBuilderMethods end end module FormBuilderMethods def date_picker(attribute, options = {}) options[:id]||= DatePicker::FormHelper.field_id(self.object_name, attribute) @template.date_picker_tag("#{self.object_name}[#{attribute}]", self.object.send(attribute), options) end def datetime_picker(attribute, options = {}) options[:id]||= DatePicker::FormHelper.field_id(self.object_name, attribute) @template.datetime_picker_tag("#{self.object_name}[#{attribute}]", self.object.send(attribute), options) end def time_picker(attribute, options = {}) options[:id]||= DatePicker::FormHelper.field_id(self.object_name, attribute) @template.time_picker_tag("#{self.object_name}[#{attribute}]", self.object.send(attribute), options) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems