Skip to content
This repository
Browse code

take into account multipart when calculating tag attributes

  • Loading branch information...
commit 8890fb80878ed4d814c5cd4a73f3c1d8694680da 1 parent 497c4bb
Aaron Patterson tenderlove authored

Showing 1 changed file with 7 additions and 4 deletions. Show diff stats Hide diff stats

  1. +7 4 actionpack/lib/action_view/helpers/form_helper.rb
11 actionpack/lib/action_view/helpers/form_helper.rb
@@ -435,9 +435,7 @@ def form_for(record, options = {}, &proc)
435 435
436 436 builder = options[:parent_builder] = instantiate_builder(object_name, object, options)
437 437 fields_for = fields_for(object_name, object, options, &proc)
438   - default_options = builder.multipart? ? { multipart: true } : {}
439   - default_options.merge! builder.form_tag_attributes
440   -
  438 + default_options = builder.form_tag_attributes
441 439 form_tag(options[:url] || {}, default_options) { fields_for }
442 440 end
443 441
@@ -1174,7 +1172,7 @@ class FormBuilder
1174 1172
1175 1173 attr_accessor :object_name, :object, :options
1176 1174
1177   - attr_reader :multipart, :parent_builder, :index, :form_tag_attributes
  1175 + attr_reader :multipart, :parent_builder, :index
1178 1176 alias :multipart? :multipart
1179 1177
1180 1178 def multipart=(multipart)
@@ -1215,6 +1213,11 @@ def initialize(object_name, object, template, options, block=nil)
1215 1213 @index = options[:index] || options[:child_index]
1216 1214 end
1217 1215
  1216 + def form_tag_attributes
  1217 + options = multipart? ? { multipart: true } : {}
  1218 + options.merge! @form_tag_attributes
  1219 + end
  1220 +
1218 1221 (field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector|
1219 1222 class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
1220 1223 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.