1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00
heartcombo--simple_form/lib/simple_form/inputs/numeric_input.rb

25 lines
579 B
Ruby
Raw Normal View History

module SimpleForm
module Inputs
class NumericInput < Base
2011-12-04 10:31:13 -05:00
enable :placeholder, :min_max
def input
add_size!
2011-12-04 09:56:05 -05:00
input_html_classes.unshift("numeric")
2011-12-04 10:15:27 -05:00
if html5?
2011-09-03 09:08:51 -04:00
input_html_options[:type] ||= "number"
input_html_options[:step] ||= integer? ? 1 : "any"
end
@builder.text_field(attribute_name, input_html_options)
end
private
# Rails adds the size attr by default, if the :size key does not exist.
def add_size!
input_html_options[:size] ||= nil
end
end
end
end