So, it looks like the webform module supplies a default value of 60 for the size attribute of a file input tag. This doesn't work too well for me -- anybody know how this can be adjusted?

Comments

abedzilla’s picture

In template.php, add this snippet

#change file field size
function phptemplate_file($element){
    $element['#size'] = 20; // this will change the size attribute to 20
    return theme_file($element);
}
gforce301’s picture

Use css in your style.css and change the displayed width of the field to whatever looks good to you.

escoles’s picture

This is about an input type=file element. You can only control the width of such an element via CSS in IE. Can't touch the width with CSS in any version of Netscape, Seamonkey or Fireforx that I've ever seen.

escoles’s picture

I feel I must be missing something in this snippet.

When I look at it, I can't see how it's supposed to work, and indeed it doesn't seem to do anything when I paste it into my template.php. Is there a code subsitition that needs to be made?

EDIT: I was missing something, alright: The right website. (Quick hint: When testing changes to template.php file, be sure to test using the site that's using the template.php you're editing!) Man, am I tired....

So now it works like a charm. And I think I even understand how.

It's so massively annoying that we have to do this. I remember tearing my hair out over FILE fields back in teh bad old pre-CSS days, and bizarrely enough, this one thing just has not changed at all.

kangaroobin’s picture

Excellent Fix!

Thanks!

MorganG’s picture

This is just what i been looking for, but unfortunately this is not working for me?

jordiserra’s picture

Not working in Drupal 7. What do I need to change in this code?

Thanks!

traviscarden’s picture

See #165672-3: Override file upload input size for code and instructions on more precisely overriding the width from your theme.