Class: FormHelper::InputAttrs
- Inherits:
-
Hash
- Object
- Hash
- FormHelper::InputAttrs
- Defined in:
- app/helpers/form_helper.rb
Instance Method Summary collapse
-
#initialize(attr, hd_cls, opts = {}) ⇒ InputAttrs
constructor
A new instance of InputAttrs.
Constructor Details
#initialize(attr, hd_cls, opts = {}) ⇒ InputAttrs
Returns a new instance of InputAttrs.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/form_helper.rb', line 65 def initialize(attr, hd_cls, opts={}) opts.reverse_merge!(html: {}) #Set html attribute hash here so :class always gets overridden in next line self.merge! opts[:html] self[:class] = (self.fetch(:class, "").split(" ") << hd_cls).join(" ") opts[:hd_opts] ||= {} opts[:data] ||= {} data = opts[:hd_opts].merge(opts[:data]) hd_config = HotDateRails.config #date_format & time_format are the only options that can be passed in at the top level of opts data[:date_format] = (opts[:date_format] || hd_config.date_format) data[:time_format] = (opts[:time_format] || hd_config.time_format) #Time grids have default values set in config/initializers/hot_date_rails.rb data[:control_type] ||= hd_config.control_type data[:hour_grid] ||= hd_config.hour_grid data[:minute_grid] ||= hd_config.minute_grid data[:second_grid] ||= hd_config.second_grid self[:data] = data end |