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

Use the same API to add size to numeric input

Also comment why we are setting the :size attr to nil in numeric inputs, due to
how Rails handles this attribute. Need to check later whether to fix this on
Rails itself.
This commit is contained in:
Carlos Antonio da Silva 2011-09-03 10:33:04 -03:00
parent 35803ba77c
commit 6b0249812e

View file

@ -4,7 +4,7 @@ module SimpleForm
enable :placeholder
def input
input_html_options[:size] ||= nil
add_size!
if SimpleForm.html5
input_html_options[:type] ||= "number"
input_html_options[:step] ||= integer? ? 1 : "any"
@ -19,6 +19,11 @@ module SimpleForm
private
# Rails adds the size attr by default, if the :size key does not exist.
def add_size!
input_html_options[:size] ||= nil
end
def infer_attributes_from_validations!
return unless has_validators?