Skip to content
Browse files

take into account multipart when calculating tag attributes

  • Loading branch information...
1 parent 497c4bb commit 8890fb80878ed4d814c5cd4a73f3c1d8694680da @tenderlove tenderlove committed Jan 2, 2013
Showing with 7 additions and 4 deletions.
  1. +7 −4 actionpack/lib/action_view/helpers/form_helper.rb
View
11 actionpack/lib/action_view/helpers/form_helper.rb
@@ -435,9 +435,7 @@ def form_for(record, options = {}, &proc)
builder = options[:parent_builder] = instantiate_builder(object_name, object, options)
fields_for = fields_for(object_name, object, options, &proc)
- default_options = builder.multipart? ? { multipart: true } : {}
- default_options.merge! builder.form_tag_attributes
-
+ default_options = builder.form_tag_attributes
form_tag(options[:url] || {}, default_options) { fields_for }
end
@@ -1174,7 +1172,7 @@ class FormBuilder
attr_accessor :object_name, :object, :options
- attr_reader :multipart, :parent_builder, :index, :form_tag_attributes
+ attr_reader :multipart, :parent_builder, :index
alias :multipart? :multipart
def multipart=(multipart)
@@ -1215,6 +1213,11 @@ def initialize(object_name, object, template, options, block=nil)
@index = options[:index] || options[:child_index]
end
+ def form_tag_attributes
+ options = multipart? ? { multipart: true } : {}
+ options.merge! @form_tag_attributes
+ end
+
(field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{selector}(method, options = {}) # def text_field(method, options = {})

0 comments on commit 8890fb8

Please sign in to comment.
Something went wrong with that request. Please try again.