input size=60 is too big (for most themes)for the file upload component. Not easy to find where to change this.

As a matter of fact, where would a person change this?

Comments

molly_n’s picture

Overriding with CSS works for IE and Opera:

input#element-id {
  width:300px !IMPORTANT;
}

But that doesn't seem to work in Firefox.

Instead, you can override Drupal's theme_file function, by adding something like the following to your theme's template.php:

function phptemplate_file($element) {
  _form_set_class($element, array('form-file'));
  return theme('form_element', $element, '<input type="file" name="'. $element['#name'] .'"'. ($element['#attributes'] ? ' '. drupal_attributes($element['#attributes']) : '') .' id="'. $element['#id'] .'" size="30" />');
}

You can change the size value to something that works for your theme. This method will, of course, impact all file input fields on your site.

quicksketch’s picture

Status: Active » Closed (fixed)
traviscarden’s picture

Title: file upload input form too big » Override file upload input size
Version: 5.x-1.4 » 6.x-3.x-dev

You can be a little more selective in your override, too. Here's code for Webform 6.x-3.x that overrides the default file upload field width only 1) for Webform components 2) where a width hasn't been specified for the instance in the GUI. It goes in your theme's template.php file.

function MYTHEMENAME_file($element) {
  if (isset($element['#webform_component']) && empty($element['#webform_component']['extra']['width'])) {
    $element['#size'] = 48;
  }
  return theme_file($element);
}
calbasi’s picture

Version: 6.x-3.x-dev » 7.x-3.9
Status: Closed (fixed) » Active

Could anybody provide the code for 7.x?

traviscarden’s picture

Status: Active » Fixed

Something like this will do the trick for you, @calbasi. (Note that it will override all file fields rendered using this theme—not just those on Webforms. I don't immediately see a way to target that way in D7.)

/**
 * Implements theme_file().
 */
function MYTHEMENAME_file($variables) {
  $variables['element']['#size'] = 48;
  return theme_file($variables);
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.