Hi,

I want to be able to change the button text on exposed filters from "Apply" to something else. I am also exposing the filters in a block, so both texts need to be changed.

I've tried the following code in my template.php: -

function phptemplate_views_filters($form) {
if ($form['#view_name'] == 'property_search') {
$form['submit']['#value']='search';
}
return theme_views_filters ($form);
}

The hook is not even being called and I cannot find any theme documentation for Views2 which covers this.

How can I go about changing the text on this button?

Many thanks,

David

Comments

merlinofchaos’s picture

Status: Active » Fixed

You can use views-exposed-form.tpl.php (it's in views/theme) to theme the exposed filter form, or you can use hook_form_alter to change the text in the button before it gets to the form.

dubs’s picture

Status: Fixed » Closed (fixed)

Thanks - I can get that to work now.

bvienneau’s picture

Which method did you use? I have the same problem.

views-exposed-form.tpl.php or hook_form_alter?

dubs’s picture

I used the views-exposed-form.top.php method. Here is a copy of the code: -

<?php
// $Id: views-exposed-form.tpl.php,v 1.4 2008/05/07 23:00:25 merlinofchaos Exp $
/**
 * @file views-exposed-form.tpl.php
 *
 * This template handles the layout of the views exposed filter form.
 *
 * Variables available:
 * - $widgets: An array of exposed form widgets. Each widget contains:
 * - $widget->label: The visible label to print. May be optional.
 * - $widget->operator: The operator for the widget. May be optional.
 * - $widget->widget: The widget itself.
 * - $button: The submit button for the form.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($q)): ?>
  <?php
    // This ensures that, if clean URLs are off, the 'q' is added first so that
    // it shows up first in the URL.
    print $q;
  ?>
<?php endif; ?>
<div class="views-exposed-form">
  <div class="views-exposed-widgets clear-block">
    <?php foreach($widgets as $id => $widget): ?>
      <div class="views-exposed-widget">
        <?php if (!empty($widget->label)): ?>
          <label>
            <?php print $widget->label; ?>
          </label>
        <?php endif; ?>
        <?php if (!empty($widget->operator)): ?>
          <div class="views-operator">
            <?php print $widget->operator; ?>
          </div>
        <?php endif; ?>
        <div class="views-widget">
          <?php print $widget->widget; ?>
        </div>
      </div>
    <?php endforeach; ?>
    <div class="views-exposed-widget">
    	<input type="submit" id="edit-submit" value="Search Properties"  class="form-submit" />
      <?php //print $button ?>
    </div>
  </div>
</div>
itowler’s picture

I would like to do the same thing, and change "Apply" to "Search"

Would all I have to do is add this line before the Print Button, and then comment out the print button?

<input type="submit" id="edit-submit" value="Search"  class="form-submit" />

Ian

merlinofchaos’s picture

That works just fine.

itowler’s picture

Indeed,

Thanks for the tips..

Ian