Sha256: e34f679718b28eef29c5913aa0e0a742d186e56f4d84d67ae5b1d8accbf82f29

Contents?: true

Size: 1.23 KB

Versions: 19

Compression:

Stored size: 1.23 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::Base::Timeish Timeish module for documentation of date, time and datetime input options.
    class TimeSelectInput 
      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(hidden_field_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

19 entries across 19 versions & 3 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/time_select_input.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/time_select_input.rb
formtastic-4.0.0 lib/formtastic/inputs/time_select_input.rb
formtastic-4.0.0.rc1 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.5 lib/formtastic/inputs/time_select_input.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.4 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.3 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.2 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.1 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.0 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.0.rc2 lib/formtastic/inputs/time_select_input.rb
formtastic-3.1.0.rc1 lib/formtastic/inputs/time_select_input.rb
formtastic-3.0.0 lib/formtastic/inputs/time_select_input.rb
formtastic-3.0.0.rc2 lib/formtastic/inputs/time_select_input.rb
formtastic-2.3.1 lib/formtastic/inputs/time_select_input.rb
formtastic-2.3.0 lib/formtastic/inputs/time_select_input.rb
formtastic-3.0.0.rc lib/formtastic/inputs/time_select_input.rb
formtastic-2.3.0.rc4 lib/formtastic/inputs/time_select_input.rb