method
apply_form_for_options!
v3.0.0 -
Show latest stable
- Class:
ActionView::Helpers::FormHelper
apply_form_for_options!(object_or_array, options)public
No documentation available.
# File actionpack/lib/action_view/helpers/form_helper.rb, line 318
def apply_form_for_options!(object_or_array, options) #:nodoc:
object = object_or_array.is_a?(Array) ? object_or_array.last : object_or_array
object = convert_to_model(object)
html_options =
if object.respond_to?(:persisted?) && object.persisted?
{ :class => options[:as] ? "#{options[:as]}_edit" : dom_class(object, :edit),
:id => options[:as] ? "#{options[:as]}_edit" : dom_id(object, :edit),
:method => :put }
else
{ :class => options[:as] ? "#{options[:as]}_new" : dom_class(object, :new),
:id => options[:as] ? "#{options[:as]}_new" : dom_id(object),
:method => :post }
end
options[:html] ||= {}
options[:html].reverse_merge!(html_options)
options[:url] ||= polymorphic_path(object_or_array)
end