diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-26 01:07:05 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-26 01:07:05 +0000 |
commit | 231a464d4e1795283410fb98b7740bed2b2e76a1 (patch) | |
tree | bfa652ab494926c6b9a6f0e8c1c532163ef9113d /actionpack | |
parent | 06dd7b8efa3073f413cf7a6b57c6a1a90a242ae1 (diff) | |
download | rails-231a464d4e1795283410fb98b7740bed2b2e76a1.tar.gz rails-231a464d4e1795283410fb98b7740bed2b2e76a1.tar.bz2 rails-231a464d4e1795283410fb98b7740bed2b2e76a1.zip |
Fixed that form elements would strip the trailing [] from the first parameter (closes #3545) [ruby@bobsilva.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3661 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 | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index e2b5970514..1e3934d512 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that form elements would strip the trailing [] from the first parameter #3545 [ruby@bobsilva.com] + * During controller resolution, update the NameError suppression to check for the expected constant. [Nicholas Seckar] * Update script.aculo.us to V1.5.3 [Thomas Fuchs] diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 9b949100bb..ac65529352 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -231,7 +231,7 @@ module ActionView DEFAULT_DATE_OPTIONS = { :discard_type => true }.freeze unless const_defined?(:DEFAULT_DATE_OPTIONS) def initialize(object_name, method_name, template_object, local_binding = nil, object = nil) - @object_name, @method_name = object_name.to_s, method_name.to_s + @object_name, @method_name = object_name.to_s.dup, method_name.to_s.dup @template_object, @local_binding = template_object, local_binding @object = object if @object_name.sub!(/\[\]$/,"") diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 20c90ea832..f0e1522807 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -68,6 +68,13 @@ class FormHelperTest < Test::Unit::TestCase assert_dom_equal expected, text_field("post", "title", :maxlength => 35) end + def test_text_field_doesnt_change_param_values + object_name = 'post[]' + expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />' + assert_equal expected, text_field(object_name, "title") + assert_equal object_name, "post[]" + end + def test_check_box assert_dom_equal( '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />', |