diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 17:27:08 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 17:27:08 +0000 |
commit | 496ee0cd1b2840fcccfa2695b8489463a548cc34 (patch) | |
tree | 18c85cc0739cb53b8ad4de12a857b30dcabff7d9 /actionpack | |
parent | 47dcc5ffc68e569cad48ac18a739f24511fff0ab (diff) | |
download | rails-496ee0cd1b2840fcccfa2695b8489463a548cc34.tar.gz rails-496ee0cd1b2840fcccfa2695b8489463a548cc34.tar.bz2 rails-496ee0cd1b2840fcccfa2695b8489463a548cc34.zip |
Fixed that FormHelper#checkbox should return a checked checkbox if the value is the same as checked_value #1286 [Florian Weber]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1317 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 8 |
3 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 63510e7bc2..80e7c72bfb 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that FormHelper#checkbox should return a checked checkbox if the value is the same as checked_value #1286 [Florian Weber] + * Fixed Form.disable in Prototype #1317 [Wintermute] * Added accessors to logger, params, response, session, and headers from the view, so you can write <% logger.info "stuff" %> instead of <% @logger.info "others" %> -- more consistent with the preferred way of accessing these attributes and collections from the controller diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 78f3f68830..fc2621ff01 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -200,6 +200,8 @@ module ActionView false when Integer value != 0 + when String + value == checked_value else value.to_i != 0 end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 21b9c24344..4e1af744b5 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -80,6 +80,14 @@ class FormHelperTest < Test::Unit::TestCase check_box("post", "secret") ) end + + def test_check_box_with_explicit_checked_and_unchecked_values + @post.secret = "on" + assert_equal( + '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" /><input name="post[secret]" type="hidden" value="off" />', + check_box("post", "secret", {}, "on", "off") + ) + end def test_radio_button assert_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />', |