aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags/file_field.rb
diff options
context:
space:
mode:
authorMauro George <maurogot@gmail.com>2014-12-08 20:22:36 -0200
committerMauro George <maurogot@gmail.com>2015-01-02 12:15:03 -0200
commit00b26532f05283d2b160308522d1bd2146d6ac18 (patch)
tree593b939899618f5fecb8134ce4ee959e835adb0d /actionview/lib/action_view/helpers/tags/file_field.rb
parent6442c90f098f7095ada0cd66bb7291b6798a5583 (diff)
downloadrails-00b26532f05283d2b160308522d1bd2146d6ac18.tar.gz
rails-00b26532f05283d2b160308522d1bd2146d6ac18.tar.bz2
rails-00b26532f05283d2b160308522d1bd2146d6ac18.zip
Add a hidden_field on the file_field
This will avoid a error be raised when the only input on the form is the `file_field`.
Diffstat (limited to 'actionview/lib/action_view/helpers/tags/file_field.rb')
-rw-r--r--actionview/lib/action_view/helpers/tags/file_field.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/tags/file_field.rb b/actionview/lib/action_view/helpers/tags/file_field.rb
index 476b820d84..02585fa0ae 100644
--- a/actionview/lib/action_view/helpers/tags/file_field.rb
+++ b/actionview/lib/action_view/helpers/tags/file_field.rb
@@ -2,6 +2,19 @@ module ActionView
module Helpers
module Tags # :nodoc:
class FileField < TextField # :nodoc:
+
+ def render
+ options = @options.stringify_keys
+ if options.fetch("include_hidden", true)
+ add_default_name_and_id(options)
+ options[:type] = "file"
+ tag("input", :name => options["name"], :type => "hidden", :value => "") + tag("input", options)
+ else
+ options.delete("include_hidden")
+ @options = options
+ super
+ end
+ end
end
end
end