public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Fixed labels that have a bracketed name and an index [#68 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
KJG (author)
Wed Apr 30 15:21:18 -0700 2008
josh (committer)
Wed Apr 30 15:21:18 -0700 2008
commit  c83f75812ef89aea1b8d138aebec25de8057f156
tree    b44d83fb5da25ea8b833037d6e074adb3bff8759
parent  96d9691e71319f4c166315a36b96c2c3c54ed493
...
471
472
473
 
474
475
476
...
471
472
473
474
475
476
477
0
@@ -471,6 +471,7 @@ module ActionView
0
         options = options.stringify_keys
0
         name_and_id = options.dup
0
         add_default_name_and_id(name_and_id)
0
+ options.delete("index")
0
         options["for"] ||= name_and_id["id"]
0
         content = (text.blank? ? nil : text.to_s) || method_name.humanize
0
         label_tag(name_and_id["id"], content, options)
...
540
541
542
 
 
 
 
 
 
 
 
 
 
 
 
543
544
545
...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
0
@@ -540,6 +540,18 @@ class FormHelperTest < ActionView::TestCase
0
       _erbout
0
   end
0
 
0
+ def test_fields_for_object_with_bracketed_name_and_index
0
+ _erbout = ''
0
+ fields_for("author[post]", @post, :index => 1) do |f|
0
+ _erbout.concat f.label(:title)
0
+ _erbout.concat f.text_field(:title)
0
+ end
0
+
0
+ assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" +
0
+ "<input name='author[post][1][title]' size='30' type='text' id='author_post_1_title' value='Hello World' />",
0
+ _erbout
0
+ end
0
+
0
   def test_form_builder_does_not_have_form_for_method
0
     assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for')
0
   end

Comments

    No one has commented yet.