aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 00:50:34 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 00:50:34 +0000
commitdf7f3455a1f850649ad7d4c0c37ccab178717956 (patch)
tree819c6a37140856ef87d3394c38d0495c9a627445 /actionpack/lib/action_view/helpers/form_helper.rb
parent94b5e57bccadbc06f13e3cf47b145e8a37dda061 (diff)
downloadrails-df7f3455a1f850649ad7d4c0c37ccab178717956.tar.gz
rails-df7f3455a1f850649ad7d4c0c37ccab178717956.tar.bz2
rails-df7f3455a1f850649ad7d4c0c37ccab178717956.zip
Added FormHelper#file_field and FormTagHelper#file_field_tag for creating file upload fields
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@750 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 36e1f946f8..b5a4403f76 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -78,6 +78,11 @@ module ActionView
InstanceTag.new(object, method, self).to_input_field_tag("hidden", options)
end
+ # Works just like text_field, but returns a input tag of the "file" type instead, which won't have any default value.
+ def file_field(object, method, options = {})
+ InstanceTag.new(object, method, self).to_input_field_tag("file", options)
+ end
+
# Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
# on an object assigned to the template (identified by +object+). Additional options on the input tag can be passed as a
# hash with +options+.
@@ -147,7 +152,7 @@ module ActionView
html_options.merge!({ "size" => options["maxlength"]}) if options["maxlength"] && !options["size"]
html_options.delete("size") if field_type == "hidden"
html_options.merge!({ "type" => field_type})
- html_options.merge!({ "value" => value_before_type_cast }) unless options["value"]
+ html_options.merge!({ "value" => value_before_type_cast }) if options["value"].nil? || field_type == "file"
add_default_name_and_id(html_options)
tag("input", html_options)
end