aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags/file_field.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib/action_view/helpers/tags/file_field.rb')
-rw-r--r--actionview/lib/action_view/helpers/tags/file_field.rb23
1 files changed, 23 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
new file mode 100644
index 0000000000..e6a1d9c62d
--- /dev/null
+++ b/actionview/lib/action_view/helpers/tags/file_field.rb
@@ -0,0 +1,23 @@
+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
+end