rails: Custom name for file_field is incorrect when using :multiple => true
In Rails 3.2.13 square brackets are appended to a custom name for file_field
when using :multiple => true
. I think this may be a bug.
The following code:
<%= f.file_field :attachment, :multiple => true, :name => 'user_file[attachment]' %>
generates the following html:
<input id="user_file_attachment" multiple="multiple" name="user_file[attachment][]" type="file" />
The reason I am setting a custom name attribute is that I want it to be:
<input id="user_file_attachment" multiple="multiple" name="user_file[attachment]" type="file" />
This does not seem to be possible when using the helper in Rails 3.2.13. I have to revert to plain HTML as a workaround.
In Rails 3.2.12 it was working like I expected it to work.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Fix explicit names on multiple file fields If a file field tag is passed the multiple option, it is turned into an array field (appending "[]"), but if the file field is passed an explicit name as an... — committed to rmm5t/rails by rmm5t 11 years ago
- Fix explicit names on multiple file fields If a file field tag is passed the multiple option, it is turned into an array field (appending "[]"), but if the file field is passed an explicit name as an... — committed to rmm5t/rails by rmm5t 11 years ago
- Squashed commit of the following: commit 714cb5a436e72d00ca0e5e6efa4b789c3e6f5b04 Author: Andrew White <andyw@pixeltrix.co.uk> Date: Wed Jul 10 16:11:33 2013 +0100 Add missing require so that ... — committed to convidera/rails by deleted user 11 years ago
- Fix multiple photo uploads. Thanks to https://github.com/rails/rails/issues/9830#issuecomment-19089244 — committed to eremite/danielesplin by eremite 11 years ago
+1
-1
@mischa78 How do you get others files? Because only one value from values of several params with the same name and without
[]
suffix is taken in account.