diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-04-05 15:30:49 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-04-05 17:47:02 -0300 |
commit | c6746ffaf4a2aeb5e4cec10c2a413f5614a6d137 (patch) | |
tree | acb09b4dd859f58f1989463e76f05e39047e84ed /actionpack/lib | |
parent | 89978f10afbad3f856e2959a811bed1982715408 (diff) | |
download | rails-c6746ffaf4a2aeb5e4cec10c2a413f5614a6d137.tar.gz rails-c6746ffaf4a2aeb5e4cec10c2a413f5614a6d137.tar.bz2 rails-c6746ffaf4a2aeb5e4cec10c2a413f5614a6d137.zip |
deprecate form_for(symbol_or_string, ...) in favor of :object_name option
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 9467a0912a..e44b43300d 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -300,15 +300,16 @@ module ActionView case record_or_name_or_array when String, Symbol + ActiveSupport::Deprecation.warn("Use the option :object_name => ... instead of a Symbol or String as a the first argument", caller) object_name = record_or_name_or_array when Array object = record_or_name_or_array.last - object_name = ActionController::RecordIdentifier.singular_class_name(object) + object_name = options[: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) + object_name = options[:object_name] || ActionController::RecordIdentifier.singular_class_name(object) apply_form_for_options!([object], options) args.unshift object end @@ -326,9 +327,13 @@ module ActionView html_options = if object.respond_to?(:persisted?) && object.persisted? - { :class => dom_class(object, :edit), :id => dom_id(object, :edit), :method => :put } + { :class => options[:object_name] ? "#{options[:object_name]}_edit" : dom_class(object, :edit), + :id => options[:object_name] ? "#{options[:object_name]}_edit" : dom_id(object, :edit), + :method => :put } else - { :class => dom_class(object, :new), :id => dom_id(object), :method => :post } + { :class => options[:object_name] ? "#{options[:object_name]}_new" : dom_class(object, :new), + :id => options[:object_name] ? "#{options[:object_name]}_new" : dom_id(object), + :method => :post } end options[:html] ||= {} |