Skip to content

Commit

Permalink
Merge pull request #988 from hooktstudios/file-field-multiple-html5
Browse files Browse the repository at this point in the history
Add support for HTML5 multiple files upload.
  • Loading branch information
Darío Javier Cravero committed Jan 6, 2013
2 parents 9cd1143 + 26aeb43 commit 5ecf1db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions padrino-helpers/lib/padrino-helpers/form_helpers.rb
Expand Up @@ -573,6 +573,7 @@ def radio_button_tag(name, options={})
#
# @api public
def file_field_tag(name, options={})
name = "#{name}[]" if options[:multiple]
options.reverse_merge!(:name => name)
input_tag(:file, options)
end
Expand Down
5 changes: 5 additions & 0 deletions padrino-helpers/test/test_form_helpers.rb
Expand Up @@ -484,6 +484,11 @@ def app
assert_has_tag(:input, :type => 'file', :class => "photo", :name => 'photo') { actual_html }
end

should "have an array name with multiple option" do
actual_html = file_field_tag(:photos, :multiple => true)
assert_has_tag(:input, :name => 'photos[]') { actual_html }
end

should "display file field in erb" do
visit '/erb/form_tag'
assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
Expand Down

0 comments on commit 5ecf1db

Please sign in to comment.