diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-31 14:32:26 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-31 14:32:26 +0000 |
commit | ed60021f39f7913537dcad181e4061e423dc6c3d (patch) | |
tree | 86532c43aabe9125422f84b48a899f2672900bf5 /actionpack/lib/action_view/helpers/form_helper.rb | |
parent | c6af337d2d6c86792cdc8132224ebe9294d35774 (diff) | |
parent | b3a028259f373fd58fea2171a1e9e8b2fe3e253a (diff) | |
download | rails-ed60021f39f7913537dcad181e4061e423dc6c3d.tar.gz rails-ed60021f39f7913537dcad181e4061e423dc6c3d.tar.bz2 rails-ed60021f39f7913537dcad181e4061e423dc6c3d.zip |
Merge remote branch 'mainstream/master'
Conflicts:
activemodel/lib/active_model/state_machine.rb
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index b81925c7e7..157deebe40 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -262,8 +262,23 @@ module ActionView # FormTagHelper#form_tag. def form_for(record_or_name_or_array, *args, &proc) raise ArgumentError, "Missing block" unless block_given? + options = args.extract_options! - object_name = extract_object_name_for_form!(args, options, record_or_name_or_array) + + case record_or_name_or_array + when String, Symbol + object_name = record_or_name_or_array + when Array + object = record_or_name_or_array.last + object_name = ActionController::RecordIdentifier.singular_class_name(object) + apply_form_for_options!(record_or_name_or_array, options) + args.unshift object + else + object = record_or_name_or_array + object_name = ActionController::RecordIdentifier.singular_class_name(object) + apply_form_for_options!([object], options) + args.unshift object + end concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {})) fields_for(object_name, *(args << options), &proc) @@ -727,25 +742,6 @@ module ActionView def radio_button(object_name, method, tag_value, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_radio_button_tag(tag_value, options) end - - private - def extract_object_name_for_form!(args, options, record_or_name_or_array) - case record_or_name_or_array - when String, Symbol - object_name = record_or_name_or_array - when Array - object = record_or_name_or_array.last - object_name = ActionController::RecordIdentifier.singular_class_name(object) - apply_form_for_options!(record_or_name_or_array, options) - args.unshift object - else - object = record_or_name_or_array - object_name = ActionController::RecordIdentifier.singular_class_name(object) - apply_form_for_options!([object], options) - args.unshift object - end - object_name - end end module InstanceTagMethods #:nodoc: |