Extract RangeField

上级 0f49caa6
......@@ -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'
......
module ActionView
module Helpers
module Tags
class RangeField < NumberField #:nodoc:
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册