Permalink
Browse files

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.
  • Loading branch information...
1 parent 35803ba commit 6b0249812e4a3c7bb5a50d2aa99751ee95a1df97 @carlosantoniodasilva carlosantoniodasilva committed Sep 3, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/simple_form/inputs/numeric_input.rb
@@ -4,7 +4,7 @@ class NumericInput < Base
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 @@ def input_html_classes
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?

0 comments on commit 6b02498

Please sign in to comment.