From b683b21bf712dd5a2cbc6ea4b5c763b9746bec73 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sun, 27 Nov 2011 13:46:08 +0300 Subject: [PATCH] simple_fields_for inherites wrapper option from the parent form, closes #357 --- lib/simple_form/action_view_extensions/builder.rb | 2 ++ test/action_view_extensions/builder_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/simple_form/action_view_extensions/builder.rb b/lib/simple_form/action_view_extensions/builder.rb index 4cbc62fb..e38c946c 100644 --- a/lib/simple_form/action_view_extensions/builder.rb +++ b/lib/simple_form/action_view_extensions/builder.rb @@ -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 diff --git a/test/action_view_extensions/builder_test.rb b/test/action_view_extensions/builder_test.rb index 94672f6b..9170944a 100644 --- a/test/action_view_extensions/builder_test.rb +++ b/test/action_view_extensions/builder_test.rb @@ -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