Small cleanup in numeric input

This commit is contained in:
Carlos Antonio da Silva 2011-09-03 10:08:51 -03:00
parent a0a7fb26c2
commit 89e861ebbb
1 changed files with 12 additions and 6 deletions

View File

@ -4,10 +4,12 @@ module SimpleForm
enable :placeholder
def input
input_html_options[:type] ||= "number" if SimpleForm.html5
input_html_options[:size] ||= nil
input_html_options[:step] ||= integer? ? 1 : "any" if SimpleForm.html5
infer_attributes_from_validations! if SimpleForm.html5
if SimpleForm.html5
input_html_options[:type] ||= "number"
input_html_options[:step] ||= integer? ? 1 : "any"
infer_attributes_from_validations!
end
@builder.text_field(attribute_name, input_html_options)
end
@ -52,9 +54,13 @@ module SimpleForm
end
def evaluate_validator_option(option)
return option if option.is_a?(Numeric)
return object.send(option) if option.is_a?(Symbol)
return option.call(object) if option.respond_to?(:call)
if option.is_a?(Numeric)
option
elsif option.is_a?(Symbol)
object.send(option)
elsif option.respond_to?(:call)
option.call(object)
end
end
end
end