Permalink
Browse files

Extract RangeField

  • Loading branch information...
1 parent 0f49caa commit f0041d4714f264bd72e9aaab055b03a7106c5990 @rafaelfranca rafaelfranca committed Jan 17, 2012
@@ -920,7 +920,7 @@ def number_field(object_name, method, options = {})
# ==== Options
# * Accepts same options as range_field_tag
def range_field(object_name, method, options = {})
- InstanceTag.new(object_name, method, self, options.delete(:object)).to_number_field_tag("range", options)
+ ActionView::Helpers::Tags::RangeField.new(object_name, method, self, options).render
end
private
@@ -970,16 +970,6 @@ def to_input_field_tag(field_type, options = {})
tag("input", options)
end
- def to_number_field_tag(field_type, options = {})
- options = options.stringify_keys
- options['size'] ||= nil
-
- if range = options.delete("in") || options.delete("within")
- options.update("min" => range.min, "max" => range.max)
- end
- to_input_field_tag(field_type, options)
- end
-
def to_boolean_select_tag(options = {})
options = options.stringify_keys
add_default_name_and_id(options)
@@ -12,6 +12,7 @@ module Tags
autoload :UrlField, 'action_view/helpers/tags/url_field'
autoload :EmailField, 'action_view/helpers/tags/email_field'
autoload :NumberField, 'action_view/helpers/tags/number_field'
+ autoload :RangeField, 'action_view/helpers/tags/range_field'
autoload :TextArea, 'action_view/helpers/tags/text_area'
autoload :CheckBox, 'action_view/helpers/tags/check_box'
autoload :RadioButton, 'action_view/helpers/tags/radio_button'
@@ -0,0 +1,8 @@
+module ActionView
+ module Helpers
+ module Tags
+ class RangeField < NumberField #:nodoc:
+ end
+ end
+ end
+end

0 comments on commit f0041d4

Please sign in to comment.