Sha256: 8df560fd9d2aa164b4f3e678b9b125fec0a2a6a2941fba8bab04474461202217

Contents?: true

Size: 1008 Bytes

Versions: 9

Compression:

Stored size: 1008 Bytes

Contents

module SimpleForm
  module Inputs
    class DateTimeInput < Base
      def input(wrapper_options = nil)
        merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)

        if use_html5_inputs?
          @builder.send(:"#{input_type}_field", attribute_name, merged_input_options)
        else
          @builder.send(:"#{input_type}_select", attribute_name, input_options, merged_input_options)
        end
      end

      private

      def label_target
        if use_html5_inputs?
          attribute_name
        else
          position = case input_type
          when :date, :datetime
            date_order = input_options[:order] || I18n.t('date.order')
            date_order.first.to_sym
          else
            :hour
          end

          position = ActionView::Helpers::DateTimeSelector::POSITION[position]
          "#{attribute_name}_#{position}i"
        end
      end

      def use_html5_inputs?
        input_options[:html5]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/inputs/date_time_input.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/inputs/date_time_input.rb
simple_form-3.4.0 lib/simple_form/inputs/date_time_input.rb
simple_form-3.3.1 lib/simple_form/inputs/date_time_input.rb
simple_form-3.3.0 lib/simple_form/inputs/date_time_input.rb
simple_form-3.2.1 lib/simple_form/inputs/date_time_input.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/simple_form-3.2.0/lib/simple_form/inputs/date_time_input.rb
simple_form-3.2.0 lib/simple_form/inputs/date_time_input.rb
simple_form-3.1.1 lib/simple_form/inputs/date_time_input.rb