Sha256: 83023d1b2b6b15b3314666f82cbab19f954a8728a06184173e770f67b9341eb1
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
Contents
module Formtastic module Inputs # Outputs a series of select boxes for the fragments that make up a time (hour, minute, second). # Unless `:ignore_date` is true, it will render hidden inputs for the year, month and day as # well, defaulting to `Time.current` if the form object doesn't have a value, much like Rails' # own `time_select`. # # @see Formtastic::Inputs::Timeish Timeish module for documetation of date, time and datetime input options. class TimeInput include Base include Base::Timeish # we don't want year / month / day fragments if :ignore_date => true def fragments time_fragments end def value_or_default_value value ? value : Time.current end def fragment_value(fragment) value_or_default_value.send(fragment) end def hidden_fragments if !options[:ignore_date] date_fragments.map do |fragment| template.hidden_field_tag("#{object_name}[#{fragment_name(fragment)}]", fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] ) end.join.html_safe else super end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems