diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-26 20:21:27 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-26 20:21:27 +0000 |
commit | 666537572d689c81eef7590f7ff3a146f3a82b29 (patch) | |
tree | 47fffa68159c5e74001ee49ff94429881c8a3233 /actionpack/lib/action_view | |
parent | 26837824555bfa749287f691e8ca96137dcfef7d (diff) | |
download | rails-666537572d689c81eef7590f7ff3a146f3a82b29.tar.gz rails-666537572d689c81eef7590f7ff3a146f3a82b29.tar.bz2 rails-666537572d689c81eef7590f7ff3a146f3a82b29.zip |
finish form_for change, allow hash as the second param: form_for :post, :url => { }.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4051 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 8380993af8..7c8748d604 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -120,10 +120,11 @@ module ActionView # form_for(name, object, options.merge(:builder => LabellingFormBuiler), &proc) # end # - def form_for(object_name, object = nil, options = {}, &proc) + def form_for(object_name, *args, &proc) raise ArgumentError, "Missing block" unless block_given? + options = args.last.is_a?(Hash) ? args.pop : {} concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}), proc.binding) - fields_for(object_name, object, options, &proc) + fields_for(object_name, *(args << options), &proc) concat('</form>', proc.binding) end @@ -141,8 +142,10 @@ 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 = nil, options = {}, &proc) + def fields_for(object_name, *args, &proc) 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)) end |