Skip to main content

How to change / remove Views2 exposed button from Drupal

Posted in

Add this to your template.php file.

  1. function YOUR_THEME_NAME_preprocess_views_exposed_form(&$vars, $hook) { //this is important
  2.  
  3.   // only alter the required form based on id
  4.   if ($vars['form']['#id'] == 'views-exposed-form-where-to-buy-page-1') {
  5.  
  6.     // Change the text on the submit button
  7.     $vars['form']['submit']['#value'] = t('Search');
  8.  
  9.     // Rebuild the rendered version (submit button, rest remains unchanged)
  10.     unset($vars['form']['submit']['#printed']);
  11.     $vars['button'] = drupal_render($vars['form']['submit']);
  12.   }
  13. }

Thanks Tom Kirkpatrick

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

If you need more help on the topic feel free to add a comment or create a new post on the Forum