diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-09-20 00:10:16 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-09-20 01:11:55 -0700 |
commit | 0523b55ab9f823b0cb3643714e890b2c2077820e (patch) | |
tree | 190d49dec912f0b34c60e0483c17654ba282b579 /actionpack/lib | |
parent | 800bab79b38949d454e0ef9b33f7cc1be912e0fa (diff) | |
download | rails-0523b55ab9f823b0cb3643714e890b2c2077820e.tar.gz rails-0523b55ab9f823b0cb3643714e890b2c2077820e.tar.bz2 rails-0523b55ab9f823b0cb3643714e890b2c2077820e.zip |
file_field propagates up multipart property even inside of fields_for
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ea59d328ea..6ca956f879 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -317,8 +317,8 @@ module ActionView options[:html] ||= {} options[:html][:remote] = options.delete(:remote) - builder = instantiate_builder(object_name, object, options, &proc) - fields_for = capture(builder, &proc) + builder = options[:parent_builder] = instantiate_builder(object_name, object, options, &proc) + fields_for = fields_for(object_name, object, options, &proc) default_options = builder.multipart? ? { :multipart => true } : {} output = form_tag(options.delete(:url) || {}, default_options.merge!(options.delete(:html) || {})) output << fields_for @@ -1119,9 +1119,14 @@ module ActionView attr_accessor :object_name, :object, :options - attr_reader :multipart + attr_reader :multipart, :parent_builder alias :multipart? :multipart + def multipart=(multipart) + @multipart = multipart + parent_builder.multipart = multipart if parent_builder + end + def self.model_name @model_name ||= Struct.new(:partial_path).new(name.demodulize.underscore.sub!(/_builder$/, '')) end @@ -1133,6 +1138,7 @@ module ActionView def initialize(object_name, object, template, options, proc) @nested_child_index = {} @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc + @parent_builder = options[:parent_builder] @default_options = @options ? @options.slice(:index) : {} if @object_name.to_s.match(/\[\]$/) if object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:to_param) @@ -1166,10 +1172,9 @@ module ActionView index = "" end - if options[:builder] - args << {} unless args.last.is_a?(Hash) - args.last[:builder] ||= options[:builder] - end + args << {} unless args.last.is_a?(Hash) + args.last[:builder] ||= options[:builder] + args.last[:parent_builder] = self case record_or_name_or_array when String, Symbol @@ -1209,7 +1214,7 @@ module ActionView end def file_field(method, options = {}) - @multipart = true + self.multipart = true @template.file_field(@object_name, method, objectify_options(options)) end # Add the submit button for the given form. When no value is given, it checks |