aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-03 04:16:58 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-03 04:16:58 +0000
commit7f6c5a56548233b8b02b09a1ac28d7b509bd26f7 (patch)
tree70de50ec253cad5b935dd6a270933f1ff407af48 /actionpack/lib/action_view/helpers/form_helper.rb
parent9a39a86f65d2fd42d15275dabeb3808bc623649c (diff)
downloadrails-7f6c5a56548233b8b02b09a1ac28d7b509bd26f7.tar.gz
rails-7f6c5a56548233b8b02b09a1ac28d7b509bd26f7.tar.bz2
rails-7f6c5a56548233b8b02b09a1ac28d7b509bd26f7.zip
Set ActionView::Base.default_form_builder once rather than passing the :builder option to every form or overriding the form helper methods.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5422 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb11
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