Sha256: e02efe40a6492475ba4ff5e8ff7e2ba2302b951eb5dc875263b05918fb742e2c

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 KB

Contents

module Formtastic
  module Inputs
    module Base
      module Numeric
        def input_html_options
          defaults = super

          # override rails default size - does not apply to numeric inputs
          #@todo document/spec
          defaults[:size] = nil
          
          if in_option
            defaults[:min] = in_option.to_a.min
            defaults[:max] = in_option.to_a.max
          else
            defaults[:min]  ||= min_option
            defaults[:max]  ||= max_option
          end
          defaults[:step] ||= step_option
          defaults
        end
        
        def step_option
          return options[:step] if options.key?(:step)
          validation_step
        end
        
        def min_option
          return options[:min] if options.key?(:min)
          validation_min
        end
        
        def max_option
          return options[:max] if options.key?(:max)
          validation_max
        end
        
        def in_option
          options[:in]
        end
        
        def wrapper_html_options
          new_class = [super[:class], "numeric", "stringish"].compact.join(" ")
          super.merge(:class => new_class)
        end
        
      end
    end
  end
end

Version data entries

22 entries across 22 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/base/numeric.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/base/numeric.rb
formtastic-4.0.0 lib/formtastic/inputs/base/numeric.rb
formtastic-4.0.0.rc1 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.5 lib/formtastic/inputs/base/numeric.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.4 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.3 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.2 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.1 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.0 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.0.rc2 lib/formtastic/inputs/base/numeric.rb
formtastic-3.1.0.rc1 lib/formtastic/inputs/base/numeric.rb
formtastic-3.0.0 lib/formtastic/inputs/base/numeric.rb
formtastic-3.0.0.rc2 lib/formtastic/inputs/base/numeric.rb
formtastic-2.3.1 lib/formtastic/inputs/base/numeric.rb
formtastic-2.3.0 lib/formtastic/inputs/base/numeric.rb
formtastic-3.0.0.rc lib/formtastic/inputs/base/numeric.rb
formtastic-2.3.0.rc4 lib/formtastic/inputs/base/numeric.rb
formtastic-2.3.0.rc3 lib/formtastic/inputs/base/numeric.rb