1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/**
 * Search box form override.
 */
function phptemplate_search_theme_form($form) {
  $form['submit']['#theme'] = 'image_button';
  $form['submit']['#attributes']['src'] = url(path_to_theme() .'/images/THEBUTTON.gif');
  return '<div id="search" class="container-inline">'. drupal_render($form) .'</div>';
}

/**
 * Custom form buttons. #theme attribute for buttons must be set to
 * "image_button" to invoke this. Values must be set through #attributes.
 *
 * Example:
 *  $form['submit']['#theme'] = 'image_button';
 *  $form['submit']['#attributes']['src'] = url(path_to_theme() .'/images/search.gif');
 */
function phptemplate_image_button($element) {
  $attributes = $element['#attributes'];
  if (!empty($element['#name'])) {
    $attributes['name'] = $element['#name'];
  }
  $attributes['class'] = (!empty($attributes['class']) ? $attributes['class'] .' ' : '') .'form-'. $element['#button_type'];
  $attributes['value'] = check_plain($element['#value']);
  return '<input type="image" '. drupal_attributes($attributes) ." />\n";
}