Skip to content

Commit

Permalink
simple_fields_for inherites wrapper option from the parent form, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Nov 27, 2011
1 parent f804874 commit b683b21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/simple_form/action_view_extensions/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def collection_check_boxes(attribute, collection, value_method, text_method, opt
# end
def simple_fields_for(*args, &block)
options = args.extract_options!
options[:wrapper] ||= self.options[:wrapper]

if self.class < ActionView::Helpers::FormBuilder
options[:builder] ||= self.class
else
Expand Down
10 changes: 10 additions & 0 deletions test/action_view_extensions/builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,14 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
end
end
end

test 'fields inherites wrapper option from the parent form' do
swap_wrapper :another do
simple_form_for(:user, :wrapper => :another) do |f|
f.simple_fields_for(:company) do |company|
assert_equal :another, company.options[:wrapper]
end
end
end
end
end

0 comments on commit b683b21

Please sign in to comment.