From c6746ffaf4a2aeb5e4cec10c2a413f5614a6d137 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 5 Apr 2010 15:30:49 -0300 Subject: deprecate form_for(symbol_or_string, ...) in favor of :object_name option --- actionpack/lib/action_view/helpers/form_helper.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'actionpack/lib') 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] ||= {} -- cgit v1.2.3