diff options
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 4bc5a8d254..8aa0b42fe1 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -142,11 +142,13 @@ module ActionView # # Note: This also works for the methods in FormOptionHelper and DateHelper that are designed to work with an object as base. # Like collection_select and datetime_select. - def fields_for(object_name, *args, &proc) + def fields_for(object_name, *args, &block) raise ArgumentError, "Missing block" unless block_given? options = args.last.is_a?(Hash) ? args.pop : {} object = args.first - yield((options[:builder] || FormBuilder).new(object_name, object, self, options, proc)) + + builder = options[:builder] || ActionView::Base.default_form_builder + yield builder.new(object_name, object, self, options, block) end # Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by +method+) on an object @@ -436,4 +438,9 @@ module ActionView end end end + + class Base + cattr_accessor :default_form_builder + self.default_form_builder = ::ActionView::Helpers::FormBuilder + end end |