Theme views exposed filters (search filter) fields
It's great to have exposed filters to search the view. But, sometimes they are too wide. This sample code shows how to change the search filter display.
In this case, I've changed the width of filter fields and the submit button label.
Put the following code in the end of your theme's template.php file:
<?php
/* Change the width of filter fields and the label of the submit button on the 'board' form */
function phptemplate_views_filters($form) {
if ($form['#view_name'] == 'board') {
$form['filter2']['#size']=15;
$form['filter3']['#size']=15;
$form['submit']['#value']='חפש';
}
return theme_views_filters ($form);
}
?>To change your own fields, simply enable the 'devel' module, print the form values with dprint_r($form), find the values you'd like to change, and change them. Then call the regular callback function to do the rest of the stuff for you.
Enjoy!
Amnon
-
Professional: Drupal Israel | Drupal Development & Consulting | Eco-Healing | Effective Hosting Strategies | בניית אתרים
Personal: Hitech Dolphin: Regain Simple Joy :)

But for those who don't know php...
...could you please give complete instructions? I can't get what should I do after editing template.php and installing devel module. What does "print the form values with dprint_r($form)" exactly mean? Could you give an example?
Thanks
This was just what I was looking for
Amnon, great work!
airali, the example has all of the code you need to change the size of a text box in an exposed view.
Find out the name of your view in Admin -> Site Building -> Views and use that where Amnon uses 'board' (keep the quotation marks).
Instead of using the devel module, you can also find out the name of the form element you want to change by loading your view and looking at the source HTML. Your text field will be named filter0, filter1, filter2, etc, or something.
What is that 3 letter word
Note, the original snippet has hebrew appearing on the submit button, change the 3 letter word to Search or submit, or whatever you need it to say.
Complete overhaul of layout
This takes the form out of the table and renders it more like a normal Drupal form.
This goes in template.php:
<?php
function phptemplate_views_filters($form) {
if ($form['#view_name'] == 'MYVIEW') {
$view = $form['view']['#value'];
$form['submit']['#value'] = 'Search';
$rows_theme = '';
foreach ($view->exposed_filter as $count => $expose) {
$rows_theme .= '<div class="filter ' . $form["filter$count"]['#name'] . '">';
$rows_theme .= '<label for="' . $form["filter$count"]['#id'] . '">'. $expose['label'] .'</label>';
$rows_theme .= drupal_render($form["op$count"]) . drupal_render($form["filter$count"]);
$rows_theme .= '</div>';
}
$rows_theme .= '<div>'. drupal_render($form['submit']) .'</div>';
return drupal_render($form['q']) . $rows_theme . drupal_render($form);
}
else {
return theme_views_filters($form);
}
}
?>
--
How to override HTML in Drupal 6
Great, thanx alot for,
Great, thanx alot for, direct and simple