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:
parent
35803ba77c
commit
6b0249812e
1 changed files with 6 additions and 1 deletions
|
@ -4,7 +4,7 @@ module SimpleForm
|
||||||
enable :placeholder
|
enable :placeholder
|
||||||
|
|
||||||
def input
|
def input
|
||||||
input_html_options[:size] ||= nil
|
add_size!
|
||||||
if SimpleForm.html5
|
if SimpleForm.html5
|
||||||
input_html_options[:type] ||= "number"
|
input_html_options[:type] ||= "number"
|
||||||
input_html_options[:step] ||= integer? ? 1 : "any"
|
input_html_options[:step] ||= integer? ? 1 : "any"
|
||||||
|
@ -19,6 +19,11 @@ module SimpleForm
|
||||||
|
|
||||||
private
|
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!
|
def infer_attributes_from_validations!
|
||||||
return unless has_validators?
|
return unless has_validators?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue