Merge pull request #369 from nashby/inherit-wrapper-option

simple_fields_for inherites wrapper option from the parent form
This commit is contained in:
Carlos Antonio da Silva 2011-11-27 04:45:25 -08:00
commit 41ac5b2127
2 changed files with 12 additions and 0 deletions

View File

@ -103,6 +103,8 @@ module SimpleForm
# 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

View File

@ -434,4 +434,14 @@ class BuilderTest < ActionView::TestCase
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