I've got a view in the admin area of my site showing an overview of content with multiple exposed filters. If I do a form alter, I can see the #size attribute of these filters is 30, but the markup that gets produced is (notice the empty size attritbute):

<input class="fluid form-text" type="text" id="edit-field-user-fname-value" name="field_user_fname_value" value="" size="" maxlength="128">

This isn't an issue in modern browsers, but IE8 treats this very differently and makes the text field tiny. I've tried hunting for the template that outputs this but can't seem to find it. This seems like a bug to me.

Comments

acbramley’s picture

Project: Views (for Drupal 7) » Rubik
Version: 7.x-3.3 » 7.x-4.0-beta8
Component: exposed filters » Code

Ok, this isn't views, this is rubik, caused by this code:

/**
 * Preprocessor for theme('textfield').
 */
function rubik_preprocess_textfield(&$vars) {
  if ($vars['element']['#size'] >= 30 && empty($vars['element']['#field_prefix']) && empty($vars['element']['#field_suffix'])) {
    $vars['element']['#size'] = '';
    if (!isset($vars['element']['#attributes']['class']) 
      || !is_array($vars['element']['#attributes']['class'])) {
       $vars['element']['#attributes']['class'] = array();
    }
    $vars['element']['#attributes']['class'][] = 'fluid';
  }
}
acbramley’s picture

Work around for this is to implement hook_preprocess_textfield in a custom module and set the size to lower than 20, or a field_prefix/suffix.

kyletaylored’s picture

Issue summary: View changes
Status: Active » Fixed

Weird, not sure why that's set to empty, to be honest. I patched it to the default HTML setting of 20.

  • kyletaylored committed 518c21d on 7.x-4.x
    Issue #1748584 by kyletaylored: Exposed text field filter gets empty...

Status: Fixed » Closed (fixed)

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