2017-10-24 01:01:08 +00:00
|
|
|
# frozen_string_literal: true
|
2010-02-06 21:21:26 +00:00
|
|
|
module SimpleForm
|
|
|
|
module Inputs
|
|
|
|
class NumericInput < Base
|
2011-12-04 15:31:13 +00:00
|
|
|
enable :placeholder, :min_max
|
2011-12-04 12:29:59 +00:00
|
|
|
|
2014-03-11 22:41:25 +00:00
|
|
|
def input(wrapper_options = nil)
|
2011-12-04 14:56:05 +00:00
|
|
|
input_html_classes.unshift("numeric")
|
2011-12-04 15:15:27 +00:00
|
|
|
if html5?
|
2011-09-03 13:08:51 +00:00
|
|
|
input_html_options[:type] ||= "number"
|
|
|
|
input_html_options[:step] ||= integer? ? 1 : "any"
|
|
|
|
end
|
2014-03-11 13:30:49 +00:00
|
|
|
|
2014-03-11 22:41:25 +00:00
|
|
|
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
|
2014-03-11 13:30:49 +00:00
|
|
|
|
|
|
|
@builder.text_field(attribute_name, merged_input_options)
|
2010-02-06 21:21:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-09-05 15:19:45 +00:00
|
|
|
end
|