simple_fields_for inherites wrapper option from the parent form, closes #357

This commit is contained in:
Vasiliy Ermolovich 2011-11-27 13:46:08 +03:00
parent f804874341
commit b683b21bf7
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