This project is archived and is in readonly mode.
File Field shouldn't include a size attribute
Reported by Dru | July 11th, 2010 @ 12:25 PM | in 3.0.2
In html5 a file input can't have a size attribute otherwise it's invalid. But using the file_field helper gives it a default size of 30:
file_field(:user, :avatar)
# => <input type="file" id="user_avatar" name="user[avatar]" size="30" />
It seems like there's 2 possible places the behaviour could be changed. Either in file_field method by setting size to nil in the default options. Or in the to_input_field_tag method (there's currently a condition for hidden field with unsets the size option).
I realise it's relatively minor (since size can just be set to nil when you call the helper) but since the rails 3 default is html5 it would be nice if the helper generated valid html5 code by default.
Apologies for not providing a patch btw, the system I'm on at the moment isn't setup for any kind of development but I wanted to post this ticket while I remembered.
Comments and changes to this ticket
-
Rohit Arondekar July 11th, 2010 @ 02:27 PM
- Importance changed from to Low
Did you try this in Rails 3 Beta 4? Looks like this has been fixed in Rails Master.
-
Dru July 11th, 2010 @ 02:49 PM
I can't see any commits that might've fixed it, but there's been so many since beta4 it would've been easy to miss. I'll have my dev machine back tuesday so I'll be able to check for sure then.
-
Miles Egan July 11th, 2010 @ 06:45 PM
It looks to me like this is still an issue in master. I've attached a patch that fixes this and adds a test case.
-
Rohit Arondekar July 12th, 2010 @ 02:03 AM
- Milestone cleared.
- Assigned user set to José Valim
- State changed from new to verified
Yes you are right! :)
+1 on the patch.
-
Repository July 13th, 2010 @ 07:37 AM
- State changed from verified to resolved
(from [d2fae5f78efd7123b9ce633933f77cbe0e0711a9]) remove size attribute from tag generated by file_field helper [#5084 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/d2fae5f78efd7123b9ce633933f77c...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5084 File Field shouldn't include a size attribute (from [d2fae5f78efd7123b9ce633933f77cbe0e0711a9]) remove ...
- 5446 HTML5 forbids the size attribute on input fields #5084 removed the size attribute from file_field input ta...