I use Drupal-7.14 and Omega sub theme. I have a view of my content type with exposed filters. When focusing input tags, HTML output is like this:

<div class="view-filters">
  <form action="/searchedlist" method="get" id="views-exposed-form-searchedlist-page-1" accept-charset="UTF-8">
      <div class="views-exposed-form">
         <div class="views-exposed-widgets clearfix">
            <div id="edit-field-bango-value-wrapper" class="views-exposed-widget views-widget-filter-field_bango_value">
              <label for="edit-field-bango-value"> BANGO </label>
                <div class="views-widget">
                  <div class="form-item form-type-textfield form-item-field-bango-value-min">
                    <input type="text" id="edit-field-bango-value-min" name="field_bango_value[min]" value="" size="30" maxlength="128" class="form-text" />
                  <div class="form-item form-type-textfield form-item-field-bango-value-max">
                    <label for="edit-field-bango-value-max">And </label>
                    <input type="text" id="edit-field-bango-value-max" name="field_bango_value[max]" value="" size="30" maxlength="128" class="form-text" />

Please show me how to change the input text size from 30 to 10 and its maxlength from 128 to 20.

for other startup people

I've reached the solution.

# mkdir sites/all/modules/mymodule
# cd sites/all/modules/mymodule
# vi mymodule.info
# cat mymodule.info
name = mymodule
description = mymodule for dummy
package = mymodule
files[] = mymodule.module
version = "7.x-1.0"
core = "7.x"
# vi mymodule.module
# cat mymodule.module
function mymodule_form_alter(&$form, &$form_state, $form_id){
  if($form_id == "views_exposed_form"){
    //dsm($form); // print $form array on the top of the page
    if (isset($form['field_bango_value']['min']) && isset($form['field_bango_value']['max'])) {
      $form['field_bango_value']['min']['#size'] = '10';
      $form['field_bango_value']['max']['#size'] = '10';
      $form['field_bango_value']['min']['#maxlength'] = '20';
      $form['field_bango_value']['max']['#maxlength'] = '20';
# wget http://ftp.drupal.org/files/projects/devel-7.x-1.3.tar.gz
# tar xzf devel-7.x-1.3.tar.gz
# mv devel modules

Admin > Modules

Check the boxes on mymodule and Devel,then Save.

Admin > config > development > performance

Clear caches.

Browse hostname/myview

Finally, HTML input tags says:

<input type="text" id="edit-field-bango-value-min" name="field_bango_value[min]" value="" size="10" maxlength="20" class="form-text" />
<input type="text" id="edit-field-bango-value-max" name="field_bango_value[max]" value="" size="10" maxlength="20" class="form-text" />

1 Answer 1


You should be able to use a regular hook_form_alter and has a great answer already, check it out and it should answer your question.

  • I could not understand of 'mymodule' in function name. I did not create my own module. What matches to mymodule? Jun 12, 2012 at 8:52
  • mymodule would be the name of the module you create, you will need to create custom modules often with Drupal, the sooner you get over that hurdle the better, it is really very easy too :)
    – WestieUK
    Jun 12, 2012 at 9:35
  • After creating my module, how do I relate the module to my view with exposed filters? Jun 12, 2012 at 10:04
  • It is in the answer I linked to "if ($form_id == 'form_views_exposed_form') { drupal_set_message("Form ID is : " . $form_id); }"
    – WestieUK
    Jun 12, 2012 at 13:12
  • I've created a dummy module and it works well.Thanks. Jun 13, 2012 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.