Created
September 16, 2010 23:37
-
-
Save spastorino/583380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb | |
index 79a9d99..97dd1f8 100644 | |
--- a/actionpack/lib/action_view/helpers/form_helper.rb | |
+++ b/actionpack/lib/action_view/helpers/form_helper.rb | |
@@ -317,8 +317,10 @@ module ActionView | |
options[:html] ||= {} | |
options[:html][:remote] = options.delete(:remote) | |
- output = form_tag(options.delete(:url) || {}, options.delete(:html) || {}) | |
- output << fields_for(object_name, object, options, &proc) | |
+ fields_for = fields_for(object_name, object, options, &proc) | |
+ default_opts = @multipart ? { :multipart => true } : {} | |
+ output = form_tag(options.delete(:url) || {}, (options.delete(:html) || {}).merge(default_opts)) | |
+ output << fields_for | |
output.safe_concat('</form>') | |
end | |
@@ -684,6 +686,7 @@ module ActionView | |
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" /> | |
# | |
def file_field(object_name, method, options = {}) | |
+ @multipart = true | |
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("file", options.update({:size => nil})) | |
end | |
@@ -871,6 +874,7 @@ module ActionView | |
raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}" | |
end | |
end | |
+ @multipart = nil | |
end | |
def to_label_tag(text = nil, options = {}, &block) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment