From 6e7b593992f8f6f8e783b87e7ab9d1d5a97063f7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 14 May 2007 17:30:35 +0000 Subject: Added record identifications to FormHelper#form_for and PrototypeHelper#remote_form_for [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6731 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/prototype_helper.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/prototype_helper.rb') diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 9fa27d6386..9bf9a71df2 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -181,8 +181,18 @@ module ActionView end # Works like form_remote_tag, but uses form_for semantics. - def remote_form_for(object_name, *args, &proc) + def remote_form_for(record_or_name, *args, &proc) options = args.last.is_a?(Hash) ? args.pop : {} + + case record_or_name + when String, Symbol + object_name = record_or_name + else + object = record_or_name + object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name) + apply_form_for_options!(object, options) + end + concat(form_remote_tag(options), proc.binding) fields_for(object_name, *(args << options), &proc) concat('', proc.binding) -- cgit v1.2.3