Module: BootstrapFormExtensions::Timespan

Includes:
Helpers
Defined in:
lib/bootstrap_form_extensions/timespan.rb

Constant Summary collapse

UNITS_IN_SECONDS =
ActiveSupport::OrderedHash[ :seconds, 1, :minutes, 60, :hours, 3600, :days, 86400, :weeks, 604800, :months, 18144000 ]
@@units =
UNITS_IN_SECONDS.keys

Instance Method Summary collapse

Methods included from Helpers

#merge_css_classes, #true?

Instance Method Details

#timespan(method, units: @@units, quantity_options: {}, unit_options: {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/bootstrap_form_extensions/timespan.rb', line 14

def timespan method, units: @@units, quantity_options: {}, unit_options: {}
  quantity, selected, units = quantity_and_units_for_timespan method, units
  hidden = hidden_field method, class: 'timespan-seconds'
  field  = text_field_for_timespan method, quantity, quantity_options
  select = select_for_timespan method, selected, units, unit_options
   :span, hidden + field + ' '.html_safe + select, data: { timespan: true }
end