Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

File Field shouldn't include a size attribute

#5084

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.

Reported by Dru · July 11th, 2010 @ 12:25 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • Importance changed from to Low

    Did you try this in Rails 3 Beta 4? Looks like this has been fixed in Rails Master.

    July 11th, 2010 @ 02:27 PM

  2. Dru
    Dru

    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.

    July 11th, 2010 @ 02:49 PM

  3. Miles Egan
    Miles Egan

    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.

    July 11th, 2010 @ 06:45 PM

  4. Rohit Arondekar
    Rohit Arondekar
    • Milestone cleared.
    • Assigned user set to José Valim
    • State changed from new to verified

    Yes you are right! :)

    +1 on the patch.

    July 12th, 2010 @ 02:03 AM

  5. Repository
    Repository
    • State changed from verified to resolved

    July 13th, 2010 @ 07:37 AM

  6. Jeremy Kemper