From a15068726f4f63fbdf830da2be8560f1b99f5d9d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 Sep 2005 08:39:23 +0000 Subject: Added :multipart option to ActiveRecordHelper#form to make it possible to add file input fields #2034 [jstirk@oobleyboo.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2193 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/active_record_helper.rb | 2 +- actionpack/test/template/active_record_helper_test.rb | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 080c675d8a..59cceba32e 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added :multipart option to ActiveRecordHelper#form to make it possible to add file input fields #2034 [jstirk@oobleyboo.com] + * Moved auto-completion and in-place editing into the Macros module and their helper counterparts into JavaScriptMacrosHelper * Added in-place editing support in the spirit of auto complete with ActionController::Base.in_place_edit_for, JavascriptHelper#in_place_editor_field, and Javascript support from script.aculo.us #2038 [Jon Tirsen] diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb index a8e78873bb..41d63fbc9a 100644 --- a/actionpack/lib/action_view/helpers/active_record_helper.rb +++ b/actionpack/lib/action_view/helpers/active_record_helper.rb @@ -71,7 +71,7 @@ module ActionView yield contents if block_given? contents << submit_tag(submit_value) - content_tag('form', contents, :action => action, :method => 'post') + content_tag('form', contents, :action => action, :method => 'post', :enctype => options[:multipart] ? 'multipart/form-data': nil) end # Returns a string containing the error message attached to the +method+ on the +object+, if one exists. diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb index cfbe3b62b7..6d416fedfb 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -119,4 +119,11 @@ class ActiveRecordHelperTest < Test::Unit::TestCase assert_equal %(

1 error prohibited this post from being saved

There were problems with the following fields:

), error_messages_for("post") assert_equal %(

1 error prohibited this post from being saved

There were problems with the following fields:

), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1") end + + def test_form_with_string_multipart + assert_equal( + %(


\n


), + form("post", :multipart => true) + ) + end end -- cgit v1.2.3