aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags/file_field.rb
blob: e6a1d9c62d07e5d8460679f3dc590c04f88520a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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