Permalink
Browse files

Fixed invalid html output for nested inputs with multiple siblings

  • Loading branch information...
1 parent dbb6e92 commit 4c5bf686b7fc5bbbc2e03c61cace101e713a51e0 @haines haines committed Oct 24, 2011
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/formtastic/helpers/inputs_helper.rb
  2. +14 −0 spec/helpers/inputs_helper_spec.rb
@@ -300,7 +300,7 @@ def inputs(*args, &block)
end
out = template.content_tag(:li, out, :class => "input") if wrap_it
- @already_in_an_inputs_block = false
+ @already_in_an_inputs_block = wrap_it
out
end
@@ -556,6 +556,20 @@
output_buffer.should have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol > li > fieldset.inputs > ol')
end
end
+
+ context "when several are nested" do
+ it "should wrap each of the nested inputs in an li block to maintain HTML validity" do
+ concat(semantic_form_for(@new_post) do |builder|
+ concat(builder.inputs do
+ concat(builder.inputs do
+ end)
+ concat(builder.inputs do
+ end)
+ end)
+ end)
+ output_buffer.should have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol', count: 2)
+ end
+ end
end

0 comments on commit 4c5bf68

Please sign in to comment.