aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 00:22:24 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 00:22:24 +0000
commita04a849d155997d0c3a6fcae4688a45c421e7a00 (patch)
treec48f0ba561eb97d1ed9c49059d70fb68f6348f86 /actionpack/lib/action_view/helpers/form_helper.rb
parent344ae8326a51beabbc5b3f4f851c3d65ec789e2d (diff)
downloadrails-a04a849d155997d0c3a6fcae4688a45c421e7a00.tar.gz
rails-a04a849d155997d0c3a6fcae4688a45c421e7a00.tar.bz2
rails-a04a849d155997d0c3a6fcae4688a45c421e7a00.zip
Clean up style around form_for and friends a bit
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3573 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, 5 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 81f6fec827..ab387b7bf8 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -121,9 +121,10 @@ module ActionView
# end
#
def form_for(object_name, object, options = {}, &proc)
- concat form_tag(options, options.delete(:html) || {}), proc.binding
+ raise ArgumentError, "Missing block" unless block_given?
+ concat(form_tag(options, options.delete(:html) || {}), proc.binding)
fields_for(object_name, object, options, &proc)
- concat '</form>', proc.binding
+ concat('</form>', proc.binding)
end
# Creates a scope around a specific model object like form_for, but doesn't create the form tags themselves. This makes
@@ -141,10 +142,8 @@ 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, object, options = {}, &proc)
- raise ArgumentError, "fields_for requires a block!" unless block_given?
- builder_klass = options[:builder] || FormBuilder
- form_builder = builder_klass.new(object_name, object, self, options, proc)
- yield form_builder
+ raise ArgumentError, "Missing block" unless block_given?
+ yield (options[:builder] || FormBuilder).new(object_name, object, self, options, proc)
end
# Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by +method+) on an object