Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed that radio buttons shouldn't have a default size attribute #1074

…[hendrik@mans.de] Added ActionView::Helpers::InstanceTag::DEFAULT_RADIO_OPTIONS that contains a hash of default options for radio buttons #1074 [hendrik@mans.de]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1127 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ac4b4701c0dc94375956f320545bff2ebe0ba832 1 parent 25d27b3
@dhh dhh authored
View
4 actionpack/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Fixed that radio buttons shouldn't have a default size attribute #1074 [hendrik@mans.de]
+
+* Added ActionView::Helpers::InstanceTag::DEFAULT_RADIO_OPTIONS that contains a hash of default options for radio buttons #1074 [hendrik@mans.de]
+
* Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar]
* Added JavascriptHelper#periodically_call_remote in order to create areas of a page that update automatically at a set interval #945 [Jon Tirsen]
View
7 actionpack/lib/action_view/helpers/form_helper.rb
@@ -145,6 +145,7 @@ class InstanceTag #:nodoc:
attr_reader :method_name, :object_name
DEFAULT_FIELD_OPTIONS = { "size" => 30 }.freeze unless const_defined?(:DEFAULT_FIELD_OPTIONS)
+ DEFAULT_RADIO_OPTIONS = { }.freeze unless const_defined?(:DEFAULT_RADIO_OPTIONS)
DEFAULT_TEXT_AREA_OPTIONS = { "wrap" => "virtual", "cols" => 40, "rows" => 20 }.freeze unless const_defined?(:DEFAULT_TEXT_AREA_OPTIONS)
DEFAULT_DATE_OPTIONS = { :discard_type => true }.freeze unless const_defined?(:DEFAULT_DATE_OPTIONS)
@@ -158,10 +159,10 @@ def initialize(object_name, method_name, template_object, local_binding = nil)
def to_input_field_tag(field_type, options = {})
options = options.stringify_keys
+ options["size"] ||= options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"]
+ options = DEFAULT_FIELD_OPTIONS.merge(options)
if field_type == "hidden"
options.delete("size")
- else
- options["size"] ||= options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"]
end
options["type"] = field_type
options["value"] ||= value_before_type_cast unless field_type == "file"
@@ -170,7 +171,7 @@ def to_input_field_tag(field_type, options = {})
end
def to_radio_button_tag(tag_value, options = {})
- options = DEFAULT_FIELD_OPTIONS.merge(options.stringify_keys)
+ options = DEFAULT_RADIO_OPTIONS.merge(options.stringify_keys)
options["type"] = "radio"
options["value"] = tag_value
options["checked"] = "checked" if value == tag_value
View
8 actionpack/test/template/form_helper_test.rb
@@ -79,10 +79,10 @@ def test_check_box
end
def test_radio_button
- assert_equal('<input checked="checked" id="post_title" name="post[title]" size="30" type="radio" value="Hello World" />',
+ assert_equal('<input checked="checked" id="post_title" name="post[title]" type="radio" value="Hello World" />',
radio_button("post", "title", "Hello World")
)
- assert_equal('<input id="post_title" name="post[title]" size="30" type="radio" value="Goodbye World" />',
+ assert_equal('<input id="post_title" name="post[title]" type="radio" value="Goodbye World" />',
radio_button("post", "title", "Goodbye World")
)
end
@@ -163,10 +163,10 @@ def test_auto_index
check_box("post[]", "secret")
)
assert_equal(
-"<input checked=\"checked\" id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"radio\" value=\"Hello World\" />",
+"<input checked=\"checked\" id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />",
radio_button("post[]", "title", "Hello World")
)
- assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"radio\" value=\"Goodbye World\" />",
+ assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
radio_button("post[]", "title", "Goodbye World")
)
end
Please sign in to comment.
Something went wrong with that request. Please try again.